Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pid_t Fork(void){ pid_t pid ; if((pid = Fork())) unix_error(Fork error); return pid;} the above is the only Fork code i find in the book Plus

image text in transcribed

pid_t Fork(void){

pid_t pid ;

if((pid = Fork()))

unix_error("Fork error");

return pid;}

the above is the only Fork code i find in the book Plus its a fixed method who only need its libary

please help me with question 8(a,b,c,d,e) from the postlab plase help me

(in C language and Unix)

Change the code such that the main process has two children instead of one. The second child should print "Line 3" followed by same information as before. Name the file "lab03e.". Show the source code in the report. a. Compile and link the source file to get the executable file "lab03e". b. Open two terminals. At the first one run the executable file, and at the second, run the command "ps f1. Show the outputs in the report. Draw the process hierarchy (grandparent, parent and children) where you state for each process its executable file name and PID. Draw the process graphs of "lab03d.c" and "lab03e.c" showing "Line x" in each branch. & Change the source file such that the main process ask the user to input number of children N) and number of grandchildren for each child (M). Then, the main process creates N child processes and each child creates M grandchild processes. Save the file as "lab3f.c". Show the source file in the report. The output should look like: Enter number of children: 3 Enter number of grand children for each child: 2 child 1 process ID xxx and its parent process ID-xxx child 2 process ID xxx and its parent process ID- xxx Child 3 process ID- xxx and its parent process ID-xxx Grandchild 1 process ID . xxx and its parent process ib-xxx Grandchild 2 process ID xxx and its parent process ID -xxx. Grandchild 1 process ID xxx and its parent process ID xxx Grandchild 2 process ID xxx and its parent process ID xxx Grandchild 1 process ID . xxx and its parent process ID-xxx Grandchild 2 process ID xxx and its parent process ID - xxx Compile and link the file to get the executable "labr Draw the corresponding process graph. Show all your work in the report. Also fill in which process printed the line (parent, childl, child2,...) verify the output using the "ps" command (use sleep to keep the processes alive). d. Fill in the following table all other correct outputs other than produced in the sample run. Sequence number Output line Which Process e Fill in a similar table for outputs that never could be produced by this program. List three such tables. Change the code such that the main process has two children instead of one. The second child should print "Line 3" followed by same information as before. Name the file "lab03e.". Show the source code in the report. a. Compile and link the source file to get the executable file "lab03e". b. Open two terminals. At the first one run the executable file, and at the second, run the command "ps f1. Show the outputs in the report. Draw the process hierarchy (grandparent, parent and children) where you state for each process its executable file name and PID. Draw the process graphs of "lab03d.c" and "lab03e.c" showing "Line x" in each branch. & Change the source file such that the main process ask the user to input number of children N) and number of grandchildren for each child (M). Then, the main process creates N child processes and each child creates M grandchild processes. Save the file as "lab3f.c". Show the source file in the report. The output should look like: Enter number of children: 3 Enter number of grand children for each child: 2 child 1 process ID xxx and its parent process ID-xxx child 2 process ID xxx and its parent process ID- xxx Child 3 process ID- xxx and its parent process ID-xxx Grandchild 1 process ID . xxx and its parent process ib-xxx Grandchild 2 process ID xxx and its parent process ID -xxx. Grandchild 1 process ID xxx and its parent process ID xxx Grandchild 2 process ID xxx and its parent process ID xxx Grandchild 1 process ID . xxx and its parent process ID-xxx Grandchild 2 process ID xxx and its parent process ID - xxx Compile and link the file to get the executable "labr Draw the corresponding process graph. Show all your work in the report. Also fill in which process printed the line (parent, childl, child2,...) verify the output using the "ps" command (use sleep to keep the processes alive). d. Fill in the following table all other correct outputs other than produced in the sample run. Sequence number Output line Which Process e Fill in a similar table for outputs that never could be produced by this program. List three such tables

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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