Question: Consider the following code: /one.c #include #include int main ( int gen-0: Ium. generations removed from original process int forknum-0 //fork #1 int pid forko

 Consider the following code: /one.c #include #include int main ( int

gen-0: Ium. generations removed from original process int forknum-0 //fork #1 int

Consider the following code: /one.c #include #include int main ( int gen-0: Ium. generations removed from original process int forknum-0 //fork #1 int pid forko (pid-0) Eorknum-1: I/identifying which fork was used gentti ) else waito print f("gen-ed : fork-id : pid-id:ppid-%d ", return 0: gen, forknum, getpid(), getppid )) And the coresponding sample exccution: $ gcc-o one one.c s .Tone gen-1:fork-1:pid-16170:ppid-16169 en-0:fork-0 pids16169:ppid-12487 A visual representation of the program is shown below: .Boxes represent processes Number inside each box indicate the process's generation (number of processes removed from original process) Arrows represent fork system calls, which point from the parent process to the child process Finally, consider the following trace of each process in a human-readable form Each entry contains: .The process id (starting from 1 and incrementing, c.g. pid 1) . The fork number (or program name, like./one) that created the process .Any logic of the code that includes: o Fork (fork 1) o print (print: gen-0:fork-0:pid-1:ppid-BASH) o wait (for when a process is stuck on a wait system call) o control structures (if, else, clse if decisions) o return (when the program completes The trace file for one.c is as follows: /one path.txt pid 1: ./one fork 1: cpid 2 wait pid 2: fork 1 print: gen-1:fork-1:pid-2:ppid-1 return pid 1: wait print: gen-0:fork-0:pid-1:ppid-BASH return Create a .c file and trace file for the following: 2. Source code + trace file for three.c Consider the following visual repesentation of a k#1 fork #3 fork #3 fork #2 fork #2 fork #3 fork #3 Write a program in C named three.c that follows the representation. Create a trace file for three.c named three path.txt. 3. Source code + trace file for alt. c Consider the following visual representation of a program: #1 fork #3 fork #3 fork fork #4 fork #4 0 fork #3 Write a program in C named alt.c that follows the representation. Create a trace file for alt.c named alt path.txt

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!