Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So the code is as follows: #include #include #include int main() { pid_t pid; int i,j; for (i =0; i if((pid=fork())==0) // child process break;

image text in transcribed

So the code is as follows:

#include

#include

#include

int main()

{

pid_t pid;

int i,j;

for (i =0; i

if((pid=fork())==0) // child process

break;

if (pid == 0)

{

if (i%2 == 0)

{

for (j =0; j

if((pid=fork())==0) // child process

break;

}

}

else // parent process

for (int i=0;i

wait(NULL);

sleep(10);

return 0;

}

before making the code i we made a table like this for some reason:

image text in transcribed

So my question is, how did we make this tree (i'm pretty sure the tree is right) and how did we make the code? I need to be able to do this for another table, same question format but i didn't understand how to do it in class.

3. Write a program using fork() to generate the following process tree (parent process id - 3440). (20 points). CARCMBPro:RPC crincon$ ps f UID PID PPID C STIME TTY 501 1316 1315 2:38PM ttys000 0:00.28-bash 501 3440 1316 0 10:38AM ttys000 0:00.00./fork 501 3441 3440 1e:38AM ttysee e:ee.ee./fork 501 3442 3440 10:38AM ttys000 :00.00-/fork 501 3443 3440 10:38AM ttys000 0:00.00 ./fork 501 3444 3441 10:38AM ttys 0:00.00 ./fork 501 3445 3441 10:38AM ttys 8:80.80 /fork 501 3446 3443 0 10:38AM ttys000 0:00.00 ./fork 501 3447 3441 10:38AM ttys000 0:00.00 ./fork 501 3448 3443 1e:38AM ttyseea e:ee.ee./fork 591 3449 3443 10 : 38AM ttysee0 0:00 . ./fork TIME CMD

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

What are the six n1ain types of occupational orientation?

Answered: 1 week ago