Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago