subject

The program shown uses the Pthreads API. What would be the output from the program at LINE C and LINE P?

#include

#include

#include

int value = 0;

void *runner(void *param); /* the thread */

int main(int argc, char *argv[])

{

pid t pid;

pthread t tid;

pthread attr t attr;

pid = fork();

if (pid == 0) { /* child process */

pthread attr init(&attr);

pthread create(&tid,&attr, runner, NULL);

pthread join(tid, NULL);

printf("CHILD: value = %d",value); /* LINE C */

}

else if (pid > 0) { /* parent process */

wait(NULL);

printf("PARENT: value = %d",value); /* LINE P */

}

}

void *runner(void *param) {

value = 5;

pthread exit(0);

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Selective incapacitation is a strategy to reduce prison population
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Write the html code to make a link out of the text “all about puppies”. it should link to a pdf called “puppies.pdf” inside the “documents” folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 03:50
Q-1 which of the following can exist as cloud-based it resources? a. physical serverb. virtual serverc. software programd. network device
Answers: 1
question
Computers and Technology, 23.06.2019 12:30
Animations and transitions are added from the
Answers: 1
You know the right answer?
The program shown uses the Pthreads API. What would be the output from the program at LINE C and LIN...
Questions
question
Geography, 21.03.2021 23:50
question
Mathematics, 21.03.2021 23:50
Questions on the website: 13722359