Question: ANSWER IN C LANGUAGE PLEASE Objective: To simulate process creation and destruction when implemented with linked lists. Specification: The program creates/destroys child processes based on

ANSWER IN C LANGUAGE PLEASE

Objective: To simulate process creation and destruction when implemented with linked lists. Specification: The program creates/destroys child processes based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are: 1) Initialize process hierarchy 2) Create a new child process 3) Destroy all descendants of a parent process 4) Quit program and free memory Assignment: Create a process creation hierarchy as an array of length MAX_PROCESSES which references process control blocks (PCBs), indexed 0 to MAX_PROCESSES-1. Each PCB is a structure consisting of two fields: o parent: a PCB index corresponding to the process creator o 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 linked list The necessary functions are simplified as follows: o create_child() represents the create function, which prompts for the parent process p. The function creates a new child process q of process p by performing the following tasks: allocate memory for an unused PCB[q] record the parent's index, p, in PCB[q] initialize the list of children of PCB[q] as empty (NULL) create a new link containing the child's index q and append the link to the children field of PCB[p] o destroy_descendants() represents the destroy function, which prompts for the parent process p. The function recursively destroys all descendent processes (child, grandchild, etc.) of process p by performing the following tasks: for each element q on the linked list of children of p: destroy_desecndants(q) (recursively destroy all descendants of q) free memory utilized by PCB[q] and set it to NULL Free memory utilized by the node with id q and set it to NULL

*TEST CASES*

1 2 0 2 0 2 2 2 0 3 2 4

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!