Shared Memory Example for (i=0; i<8; i++) a[i] = b[i] + c[i]; sum = 0; for (i=0; i<8; i++) if (a[i] > 0) sum = sum + a[i]; Print sum; begin parallel /
{"Image DocumentName": "Shared Memory Example Sequential Parallel", "Image ImageDescription": "begin parallel // spawn a child thread. private int start_iter, end_iter, i; shared int local_iter=4, sum=0; shared double sum=0.0, a[], b[], c[]; shared lock_type mylock; start_iter = getid()   local_iter; end_iter = start_iter + local_iter; for (i=start_iter; i<end_iter; i++) a[i] = b[i] + c[i]; barrier; if (a[i] > 0) { lock(mylock); sum = sum + a[i]; unlock(mylock); } barrier; // necessary. end parallel // kill the child thread. Print sum; for (i=0; i<8; i++) a[i] = b[i] + c[i]; sum = 0; if (a[i] > 0) sum = sum + a[i]; Print sum; Sequential. Parallel.", "Image XResolution": "37", "Image YResolution": "37", "Image ResolutionUnit": "Pixels/Centimeter", "Image Software": "SlidePlayer", "Image YCbCrPositioning": "Centered"}