[SOLVED] CMSC 412 Homework 2

35.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

Write a C program for UNIX that creates three processes, a grandparent (G), a parent (P) and a child (C). The first process is the grandparent G, which creates the process P (the parent) and then waits until P finishes its execution. Process P in turn, will create the child process C and waits until C finishes its execution. More precisely, the following list describes the behavior of each process:
1. Process G will create process P, will wait for process P to finish its execution, and then will display its own pid.
2. Process P will create process C, will wait for process C to finish its execution, and then will display its own pid and the pid of process G (its parent).
3. Process C will display its own pid, the pid of process P (its parent) and the pid of process G (its grandparent)
When run, the program will display the following (where X, Y, Z are numbers representing process ids):
I am the child process C and my pid is X. My parent P has pid Y. My grandparent G has pid Z.
I am the parent process P and my pid is Y. My parent G has pid Z.
I am the grandparent process G and my pid is Z.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.