Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include include include #include nt nain() { int nun-21 int pid = fork(); if (pld--) nun = num + 8; pld fork) if (pid !=
#include include include #include nt nain() { int nun-21 int pid = fork(); if (pld--) nun = num + 8; pld fork) if (pid != 0) wait (NULL); else pld fork) nun = num+ 12; unnum 20; fork valt(NULL printf"dn",num) return 0; a. [8] Ifall forks are successful, how many processes are created by running this piece of code? Include main (0) in your answer. To support your answer, you must draw a tree diagram showing the hierarchy of processes that are created as the program runs. Number the process as we did in class, where main is 0, children of 0 are 1,2,3. thfirst child of is 11, the second child of 1 is 12, the first child of 2 is 21, etc b. 3] Does this code result in any zombie processes? Why or why not? c 5 What would the process tree look like if an exec system call that executed the 1. command were inserted between the second int num 2 and third int pid fork instructions
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started