Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operating Systems Unix fork() Submission: 1. two_path.txt 2. three.c 3. three_path.txt 4. alt.c 5.alt_path.txt Background Consider the following code: /one. #include #include int main) int

Operating Systems Unix fork()

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Submission:

1. two_path.txt

2. three.c

3. three_path.txt

4. alt.c

5.alt_path.txt

Background Consider the following code: /one. #include #include int main) int gen-0 /um. generations removed from original process int forknum-0 / / fork #1 int pid-fork O if (pid0) forknum-1: 1/identifying which fork was used gen++ ) else wait printf ( "gen-%d : fork-ed:pid-id:ppia-%d ", return 0 gen, forknum, getpid(), getppid)) And the corresponding sample execution: gcc-o one one.c $ ./one gen-1:fork-1:pid-16170:ppid-16169 en-0: fork-0:pid-16169: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, e.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, else if decisions) o return (when the program completes) The trace file for one.c is as follows: /lone path.txt pid 1: ./one fork : cpid2 wait pid 2: fork 1 print: gen-1:fork-1:pd-2:ppid-1 return pid 1: wait print: gen-0:fork-0:pid-1:ppid-BASH return Trace files like one_path.txt are not programmatically generated but by a person mentally stepping through the program. A visual representation of the program: fork #2 fork #2 Create a trace file for two.c named two_path.txt. 2. Source code + tra Consider the following visual representation of a program: ce file for three.c 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. Background Consider the following code: /one. #include #include int main) int gen-0 /um. generations removed from original process int forknum-0 / / fork #1 int pid-fork O if (pid0) forknum-1: 1/identifying which fork was used gen++ ) else wait printf ( "gen-%d : fork-ed:pid-id:ppia-%d ", return 0 gen, forknum, getpid(), getppid)) And the corresponding sample execution: gcc-o one one.c $ ./one gen-1:fork-1:pid-16170:ppid-16169 en-0: fork-0:pid-16169: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, e.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, else if decisions) o return (when the program completes) The trace file for one.c is as follows: /lone path.txt pid 1: ./one fork : cpid2 wait pid 2: fork 1 print: gen-1:fork-1:pd-2:ppid-1 return pid 1: wait print: gen-0:fork-0:pid-1:ppid-BASH return Trace files like one_path.txt are not programmatically generated but by a person mentally stepping through the program. A visual representation of the program: fork #2 fork #2 Create a trace file for two.c named two_path.txt. 2. Source code + tra Consider the following visual representation of a program: ce file for three.c 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

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

More Books

Students also viewed these Databases questions

Question

=+What is the big message you want them to know?

Answered: 1 week ago

Question

=+What do they (audience members) currently think?

Answered: 1 week ago