Question: Question 3 [ Points 5 ] Modify and run the program shown below in the following way. There is an array of 2 0 elements
Question Points Modify and run the program shown below in the following way. There is
an array of elements defined in the program. The elements of the array are:
Thread adds the first four
elements Thread adds the next four elements Thread adds
the last four elements Finally, the sum of all the elements is printed by the
main program. The parent must wait for all threads to complete before printing the output. Run
and show the output.
include
#include
#include
#define NUMTHREADS
int counter;
void PrintHellovoid threadid
counter counterint threadid;
printf
Thread Id: d Counter: d
threadid, counter;
pthreadexitNULL;
int mainint argc, char argv
pthreadt threadsNUMTHREADS;
int rc t;
fort;t
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
