Question: Specication: The program createsfdestroys child processes based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are:

 Specication: The program createsfdestroys child processes based on choosing from amenu of choices, where each choice calls the appropriate procedure, where the

Specication: The program createsfdestroys child processes based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are: 1) Enter parameters 2) Create a new child process 3) Destroy all descendants of a process 4) Quit program and free memory Assignment: I Create a process creation hierarchy as a dynamic array of length n which references the process control blocks (PCBs), indexed 0 to nl 0 Each PCB is a structure consisting of two elds: 0 parent: 3 PCB index corresponding to the process' creator 0 children: a pointer to a linked list, where each node contains the PCB index of one child process and a link to the next child in the list 0 The necessary functions are simplified as follows: 0 create() represents the create function, which prompts for the parent process PCB [p]. The function creates a new child process PCB[q] of process PCB [p] by performing the following tasks: I allocate a free PCB[q] I record the parent's index, p, in PCB [q] I initialize the list of children of PCB [q] as empty (NULL) I create a new link containing the child's index q and append the link to the linked list of PCB [p] o destroyO represents the destroy function, which prompts for the parent process PCB [p]. The function recursively destroys all descendent processes (child, grandchild, etc.) of process PCB[p] by performing the following tasks: for each element q on the linked list of children of PCB[p]: I destroy(q) P\" recursively destroy all descendants *f I free PCB[q] I deallocate the element q from the linked list What NOT to do: a Do NOT modify the choice values (1 2,3,4) or input characters and then try to convert them to integersthe test script used for grading your assignment will not work correctly. Sample output Process creation and destruction 1) Enter parameters 2} Create a new child process 3) Destroy all descendants of a process 4} Quit program and free memory Enter selection: 1 Enter maximum number of processes: 5 Process creation and destruction 1} Enter parameters 2} Create a new child process 3) Destroy all descendants of a process 4) Quit program and free memory Enter selection: 2 Enter the parent process index: 0 PCBEO] is the parent of: PCEEI] Process creation and destruction 1) Enter parameters 2} Create a new child process 3} Destroy all descendants of a process 4) Quit program and free memory Enter selection: 2 Enter the parent process index: 0 PCB[O] is the parent of: PCEII] PCB[2] Process creation and destruction 1) Enter parameters 2) Create a new child process 3) Destroy all descendants of a process 4) Quit program and free memory Enter selection: 2 Enter the parent process index: 2 PCE[O] is the parent of: PCEIl] PCE[2] PCB[2] is the parent of: PCE[3] Process creation and destruction 1) Enter parameters 2} Create a new child process 3} Destroy all descendants of a process 4) Quit program and free memory Enter selection: 2 Enter the parent process index: 0 PCBEO] is the parent of: PCEEl] PCE[2] PCBI4] PCB[2] is the parent of: PCE[3] Process creation and destruction 1) Enter parameters 2} Create a new child process 3} Destroy all descendants of a process 4) Quit program and free memory Enter selection: 3 Enter the index of the process whose descendants are to be destroyed: 0 Process creation and destruction 1) Enter parameters 2) Create a new child process 3} Destroy all descendants of a process 4} Quit program and free memory Enter selection: 4 Quitting program

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 Programming Questions!