- 1 Figure 3 Shows A Code For A Program Named Frk A What Is The Total Number Of Processes Excluding The Bash That 1 (226.15 KiB) Viewed 21 times
1. Figure 3 shows a code for a program named "FRK". (a) What is the total number of processes (excluding the bash) that
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. Figure 3 shows a code for a program named "FRK". (a) What is the total number of processes (excluding the bash) that
1. Figure 3 shows a code for a program named "FRK". (a) What is the total number of processes (excluding the bash) that will run on the system from executing this program [5 marks], (b) draw the process tree of this program (assuming that code line #19 is being executed) [5 marks], (c) write down the program outputs (assuming all processes have finished executing) [5 marks], (d) give two reasons of why having child_pid to capture the return value of the fork() [5 marks]. [total 20 marks]. 1#include <stdio.h> 2 #include <unistd.h> 3 #include <sys/types.h> 4 5 int main() 6 { pid_t child_pid; child_pid fork(); if (child_pid != 0) { fork(); printf ("A\n"); sleep (100); 14 } 15 else { sleep (1);//so that the parent will execute first char* arg_list[] = {"uname","-s", NULL}; //-s, --kernel-name execvp ("uname", arg_list); fork(); printf ("B\n"); } printf ("C\n"); return 0; Figure 3. Source code of a program named "FRK". 789OHN MAS6 LEDLADDAREN 10 11 12 13 16 17 18 19 20 21 22 23 24 25} LE