Question: Write pesudo code of the fiven code #include #include #include #include void *computinParallelPiSerial(int start, int end, double *sum) { int i; //printf(looping from %d to

Write pesudo code of the fiven code

#include #include #include #include

void *computinParallelPiSerial(int start, int end, double *sum) { int i; //printf("looping from %d to %d ",start, end ); double factor; for (i = start; i < end; i++){ if (i % 2 == 0){ factor = 1.0; } else { factor = -1.0; } *sum = *sum + 4 * factor / (2*i+1); } return NULL; }

int main(){ double sum = 0; long start=0,last=0, n = 100000; int i=0; void *status; // holds the thread execution status int threadCount = 4; pthread_t thread_ids[threadCount];

for (i = 0; i < threadCount; i++){ start = last; last = start+n/threadCount; pthread_create(&thread_ids[i], NULL, computinParallelPiSerial(start,last,&sum), NULL); }

//for (i = 0; i < threadCount; i++) // pthread_join(&thread_ids[i], NULL);

printf("Pi is equal to %f ", sum); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!