Question: 2 Consider the parent process as P. The program consists of fork() system call statements placed at different points in the code to create new

 2 Consider the parent process as P. The program consists offork() system call statements placed at different points in the code to

2 Consider the parent process as P. The program consists of fork() system call statements placed at different points in the code to create new processes Q and R. The program also shows three variables: a, b, and pid - with the print out of these variables occurring from various processes. Show the values of pid, a, and b printed by the processes P, Q, and R. int a-10, b=25, fq=0, fr=0 fq=fork() // fork a child - call it Process Q if(fq==0){ // Child successfully forked a=a+b print values of a, b, and process_id fr=fork() // fork another child - call it Process R if(fr !=0){ b=b+15 1/print values of a, b, and process_id }else{ a=(a*b)+20 //print values of a, b, and process_id } }else{ b=a+b-5; print values of a, b, and process_id Q2: Type and run the code to get the values of a, b, and process id. Briefly write your interpretation (in a text file) on working of the code to explain how your code arrives at the values you printed out. Note, run your program for Part 2 multiple times and see whether there are any changes in the order of execution before writing your report

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!