Question: includ includ@ (pthread. h include int value 0 void rusner(void paran); int pid: pthreadt tid pthread attr.t attr: pid - forkO: if pid 0)

 includ includ@ (pthread. h include int value 0 void rusner(void paran);

includ includ@ (pthread. h include int value 0 void rusner(void paran); int pid: pthreadt tid pthread attr.t attr: pid - forkO: if pid "" 0) pthread attr init (kattr) pthread create(ktid,tattr,runner, NULL) pthread join tid,NULL) printf(A: value Xdin",value) else if (pid > 0) { vait (ULL) printf ("B: value-%dia", value); void runner(void .paran) value 5 pthread exit (o) Given the above code, answer the following three questious and one modification of the code 1. What does this progras output at A: and B:? 2 Mark each line of code in the program as either (1) exccuted by parent process, (2) exncuted as child process, (3) executed by a new thread spawned by the parent or (4) executed by a thread spawnl by the child process 3. Provide a one line description (as an inline comment) for each program line above. Make sure you concisely but clearly describe what the program is doing at each line 4. Modify the oode so that both threads keep printing the same line, so that the terminal show 'A' and B' interleavely includ includ@ (pthread. h include int value 0 void rusner(void paran); int pid: pthreadt tid pthread attr.t attr: pid - forkO: if pid "" 0) pthread attr init (kattr) pthread create(ktid,tattr,runner, NULL) pthread join tid,NULL) printf(A: value Xdin",value) else if (pid > 0) { vait (ULL) printf ("B: value-%dia", value); void runner(void .paran) value 5 pthread exit (o) Given the above code, answer the following three questious and one modification of the code 1. What does this progras output at A: and B:? 2 Mark each line of code in the program as either (1) exccuted by parent process, (2) exncuted as child process, (3) executed by a new thread spawned by the parent or (4) executed by a thread spawnl by the child process 3. Provide a one line description (as an inline comment) for each program line above. Make sure you concisely but clearly describe what the program is doing at each line 4. Modify the oode so that both threads keep printing the same line, so that the terminal show 'A' and B' interleavely

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!