Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following program in c #include #include catalib.h> #include int main() pid t x = 0; int i; for (i=1;i 1 is a constant

image text in transcribed
image text in transcribed
image text in transcribed
Consider the following program in c #include #include catalib.h> #include int main() pid t x = 0; int i; for (i=1;i 1 is a constant defined in the beginning of the program through a #define statement Assume that all fork() calls complete successfully Note that "getpid(" and "getppid" are two system calls that return the process identifier of the calling process and the process identifier of the calling process's parent, respectively. 1) How many processes are created during the execution of this program (including the parent process)? Explain your answer to get credit. 1.) Give the process hierarchy tree for this program (see slide 2.15 for an example process hierarchy treo). [You can explain the hierarchy in writing as opposed to drawing, if it's easier. For example, you can say there are three processes: parent process A, a process B (child of A), another process C (child of Br" if you believe there are three processes with the given parent-child relationships] ill) How many lines of the output would be printed? Explain your answer to get credit. iv.) Now assume that the first process to enter the "for loop has the process identifier 1000 and it is spawned by a shell process which has the process identifier 900. Further, assume all the spawned processes thereafter in this program receive consecutive process identifiers (i.e., 1001, 1002, 1003, ...) iv.) Now assume that the first process to enter the "for" loop has the process identifier 1000 and it is spawned by a shell process w the process identifier 900. Further, assume all the spawned processes thereafter in this program receive consecutive process iden (1.e., 1001, 1002 1003, ...) Assuming a large N, what would be the first two lines and the last line of the output? Explain your answer to get credit. (you can refer to N in your answer). Consider the following program in c #include #include catalib.h> #include int main() pid t x = 0; int i; for (i=1;i 1 is a constant defined in the beginning of the program through a #define statement Assume that all fork() calls complete successfully Note that "getpid(" and "getppid" are two system calls that return the process identifier of the calling process and the process identifier of the calling process's parent, respectively. 1) How many processes are created during the execution of this program (including the parent process)? Explain your answer to get credit. 1.) Give the process hierarchy tree for this program (see slide 2.15 for an example process hierarchy treo). [You can explain the hierarchy in writing as opposed to drawing, if it's easier. For example, you can say there are three processes: parent process A, a process B (child of A), another process C (child of Br" if you believe there are three processes with the given parent-child relationships] ill) How many lines of the output would be printed? Explain your answer to get credit. iv.) Now assume that the first process to enter the "for loop has the process identifier 1000 and it is spawned by a shell process which has the process identifier 900. Further, assume all the spawned processes thereafter in this program receive consecutive process identifiers (i.e., 1001, 1002, 1003, ...) iv.) Now assume that the first process to enter the "for" loop has the process identifier 1000 and it is spawned by a shell process w the process identifier 900. Further, assume all the spawned processes thereafter in this program receive consecutive process iden (1.e., 1001, 1002 1003, ...) Assuming a large N, what would be the first two lines and the last line of the output? Explain your answer to get credit. (you can refer to N in your answer)

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Respond to the questions in Consumer Insight 42.

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago