1. Engineering
  2. Computer Science
  3. operating system logic based on the code below please answer...

Question: operating system logic based on the code below please answer...

Question details

//Operating System Logic//

Based on the code below, Please answer the questions pertaining to the code.

1FIG1 int main () pid_t pid; pid fork /* fork a child process / if (pid < 0)/error occurred return Li else if (pid0) / child process */ execlp(/bin/ls, 1s,NULL) printf LINE J) else / parent process/ wait (NULL) printf (Child COmplete) return 0 FIG 2 int main() int i; fork ) return 0 int main () pid t pid, pid1; pid = fork(); /* fork a child process */ if (pid < 0) { /* error occurred return 1 else if (pid-0) { /* child proces */ pidl getpid printf ( child: Rid-%d, pid); /** A **) printf( child: pidld,pid1)/ B else { /* parent process pidl getpid print f (child: printf (child: wait (NULL) pid-%d , pid); /** pidi :: %d, pidi);/** C D **, **) return 0

1. Explain any circumstances under which the line of code marked printf (LINE J) in FIG 1 may be reached. 2. Including the initial parent process, how many processes are created by the program in FIG 2? Processes 3. Using the program in FIG 3, identify the values of pid at line A, B, C, and D. (Assume that the actual pids of the parent and child are 1111 and 2222, respectively) A- pid B- pid1 c-pid D - pid1

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution