Threads Task # 1 Write a program using pthreads, which calculates the sum of elements in a hard-coded integer array in parallel using 4 threads. The program must divide the work between 4 threads...


Threads<br>Task # 1<br>Write a program using pthreads, which calculates the sum of elements in a hard-coded integer<br>array in parallel using 4 threads. The program must divide the work between 4 threads which run<br>simultaneously. For simplicity, you can assume that the size of the array is 100. Note that the<br>integer array must be declared as a global data structure. Initially code your solution so that the<br>sum of elements is maintained in a global shared variable. Each thread modifies the same shared<br>variable as it sums up elements from the array. Use a suitable synchronization primitive (mutex)<br>

Extracted text: Threads Task # 1 Write a program using pthreads, which calculates the sum of elements in a hard-coded integer array in parallel using 4 threads. The program must divide the work between 4 threads which run simultaneously. For simplicity, you can assume that the size of the array is 100. Note that the integer array must be declared as a global data structure. Initially code your solution so that the sum of elements is maintained in a global shared variable. Each thread modifies the same shared variable as it sums up elements from the array. Use a suitable synchronization primitive (mutex)

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here