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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:20, codie1103
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
image
Computers and Technology, 22.06.2019 15:30, 1232444553
Which of the following examples has four beats in each measure?
Answers: 2
image
Computers and Technology, 22.06.2019 21:00, jarrettashlyn
Write a method so that the main() code below can be replaced by the simpler code that calls method original main(): public class calcmiles { public static void main(string [] args) { double milesperhour; double minutestraveled; double hourstraveled; double milestraveled; milesprhour = scnr. nextdouble(); minutestraveled = scnr. nextdouble(); hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; system. out. println("miles: " + milestraveled); } }
Answers: 2
image
Computers and Technology, 23.06.2019 06:20, kiarakagni
What is a point-in-time measurement of system performance?
Answers: 3
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 in other subjects:

Konu
Mathematics, 22.10.2020 23:01
Konu
Mathematics, 22.10.2020 23:01
Konu
Mathematics, 22.10.2020 23:01