Question: The user-level program segment below shows the usage of the fork() and getpid() system calls under Linux. TWO possible sample outputs could be resulted after

The user-level program segment below shows the usage of the fork() and getpid() system calls under Linux. TWO possible sample outputs could be resulted after the program is successfully executed. pid_t child_pid; child_pid = fork(); if (child pid != 0) { int status; printf("This is parent, id = %d ", getpid()); // for part (c) // for part (c) } else printf ("This is child, id %d ", getpid()); Sample Output 1 This is child, id = 13920 This is parent, id 13919 Sample Output 2 This is parent, id = 8520 This is child, id = 8521 (a) State the usage of the fork() and getpido system calls, and hence explain the output of the program above. (3 marks) (b) Output messages are displayed in different order under different executions (see sample output 1 and 2 above) due to race condition". Define what a race condition" is. (2 marks) (C) Suppose blank >> above is filled in the code below: sleep (10), As a result, during the 10-second interval when the parent process "sleeps, a zombie process is found in the system (1) What is the difference between a zombie process and an orphan process? (2 marks) (ii) Write down the code to be inserted in blank so that there is no zombie process during the time when the parent process "sleeps". (Hint: You may find the integer variable status useful in your answer). (1 mark)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
