Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this and the next question, assume the following code successfully compiles and runs on a modern linux machine ( assume any irrelevant details have

For this and the next question, assume the following code successfully compiles and runs on a modern linux machine (assume any irrelevant details have been omitted; also assume that all required header files are included):
int balance =0;
void *mythread(void *arg){
int i;
for (i=0; i<200; i++){
balance++;
}
printf("Balance is %d
", balance);
return NULL;
}
int main(int argc, char *argv[]){
pthread_t p1, p2, p3;
pthread_create(&p1, NULL, mythread, "A");
pthread_join(p1, NULL);
pthread_create(&p2, NULL, mythread, "B");
pthread_join(p2, NULL);
pthread_create(&p3, NULL, mythread, "C");
pthread_join(p3, NULL);
printf("Final Balance is %d
",balance);
}
Assuming none of the functions calls fail, when thread p2 prints "Balance is %d
", what will p2 say is the value of balance ?
Group of answer choices
400
0
600
200

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

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

80 HR ethics and professional standards.

Answered: 1 week ago

Question

Write a note on job design.

Answered: 1 week ago

Question

Compute the derivative of f(x)cos(-4/5x)

Answered: 1 week ago

Question

Discuss the process involved in selection.

Answered: 1 week ago

Question

Differentiate tan(7x+9x-2.5)

Answered: 1 week ago