Question: Q1. Write a program using fork() system call to create two child of the same process i.e., Parent P having child process P1 and P2.

Q1. Write a program using fork() system call to create two child of the same process i.e., Parent P having child process P1 and P2.

Q2. Write a program using fork() system call to create a hierarchy of 3 process such that P2 is the child of P1 and P1 is the child of P.

Q3. How many total process are created with the below code int main() { fork(); fork(); fork(); }

Q4. Write a program to create two child process. The parent process should wait for both the child to finish.

Q5. Create a parent-child relationship between two process. The parent should print two statements: A) its own PID B) PID of its child The child should print two statements: C) its own PID D) PID of its parent Make use of wait() in such a manner that the order of the four statements A, B, C and D is: A C D B You are free to use any other relevant statement/printf as you desire and their order of execution does not matter.

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!