Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribed
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

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

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago