Question: Trace the following program and answer the following questions: #include #include #include void *square (void *param); int x = 10; int main (int argc, int

Trace the following program and answer the following questions:

#include

#include

#include

void *square (void *param);

int x = 10;

int main (int argc, int argv[]){

pthread_t tid[3];

for (int i=0; i

pthread_create(&tid[i], NULL, *square, i+1);

for (int i=0; i

pthread_join (tid[i], NULL);

}

void * square (void *param){

int y=x*x ;

printf ("The %d double is %d ",param,y);

pthread_exit(0); }

Trace the following program and answer the following questions: #include #include #include

How many threads are created by phread_create? Is the thread ID the same as the process ID (Yes/No)? . What is the name of the function that was executed by all threads? . . What is the parameter that was passed to the thread function? Answer with True or False: o Variable (x) is a Local shared variable among all threads. o Variable (y) is a Local not shared variable among all threads. o Variable (x) is a shared variable among all threads. o The value of y of the first executed thread is 100. o The value of y of the second executed thread is 10000. o If the main program does not call thread_join() after creating a thread, then the main process will be blocked until all threads are terminated successfully

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!