Question: 18. Refer to this code snippet when answering the following questions. int main() { int some_number = 1; pid t pid fork (); if

18. Refer to this code snippet when answering the following questions. int

 

18. Refer to this code snippet when answering the following questions. int main() { int some_number = 1; pid t pid fork (); if (pid == 0) { } some_number = 0; if (fork () == 0) some_number = 3; else if (pid > 0) { if (fork() == 0) { } else some_number = 2; cout < < some_number; } return 0; } a. Draw a tree of processes to illustrate the parent/child relationships between all of the processes created by fork when this program runs. (4 pts) b. Is it possible to predict the value of some_number that is displayed on the terminal? If so, list the number; otherwise, explain why the value is unpredictable. (2 pts)

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 Programming Questions!