You are on page 1of 2

Assignment OS

Prof. Nabeel Sabir Q1. Using fork system call generate following tree.

Proc 1 Proc 1.1 Proc 1.1.1 Proc 1.1.1.1 Proc 1.1.2 Proc 1.2 Proc 1.2.1 Proc 1.2.1.1 Proc 1.2.2 Proc 1.2.2.1

After creating the above tree solve following the questions: What is the Process ID of Proc 1.1.1.1? Kill Proc 1.1 What is the state of Proc 1.1.1 and Proc 1.1.2 and what happened to Proc 1.1.1.1? Who is the parent of Proc 1.1.1 and Proc 1.1.2? What is the Parent ID of Proc 1.2.1? Change the Parent of Proc 1.2.1.1 from Proc 1.2.1 to Proc 1.2.2.1. Change the Process ID of Proc 1.2.2.1? Create the same tree using vfork and clone command and analyze the difference between trees. 9. What do you think can Proc 1.1 call a procedure from Proc 1.2 if Process ID is known? 10. Block the process Proc 1.2 from termination until all of its child process terminated. 11. Block the process Proc 1 from termination until Proc 1.2 terminated. 12. In question 2 when you killed Proc 1.1 its child processes get orphaned how can you stop this? What do you call an orphaned process in Linux? Hints: Wait command is used for blocking a process. You need to maintain groups and process ids in order to manage orphan processes. 1. 2. 3. 4. 5. 6. 7. 8.

Note: You need to submit all codes and the process you are solving the questions. For example in Q1 you need to tell the process id, you should write the commands by which you get the process id. Also attach the results with your assignment.

Question 2: You have to write a program which creates a child a and the the child a creates two childs b and c. B returns 1 and c returns 2. Then a returns the sum of these both returns it which is then printed by its parent.

You might also like