Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Written in C, please, and thank you! 11.1 Two versions of the process creation hierarchy Project objective Compare the performance of process creation and destruction
Written in C, please, and thank you!
11.1 Two versions of the process creation hierarchy Project objective Compare the performance of process creation and destruction when implemented with and without linked lists. Description Version 1 of the process creation hierarchy uses linked lists to keep track of child processes as described in section "The process control block", subsection "The PCB data structure". For the purposes of performance evaluation, the PCBs are simplified as follows: All PCBs are implemented as an array of size n. Each process is referred to by the PCB index, O through n-1. Each PCB is a structure consisting of only the two fields: parent: a PCB index corresponding to the process's creator children: a pointer to a linked list, where each list element contains the PCB index of one child process The necessary functions are simplified as follows: create() represents the create function executed by process PCB[p]. The function creates a new child process PCB[] of process PCB[p] by performing the following tasks: allocate a free PCB[q] o record the parent's index, p, in PCB[c] initialize the list of children of PCB[] as empty o create a new link containing the child's index q and appends the link to the linked list of PCB[b] destroy(D) represents the destroy function executed by 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 on the linked list of children of PCB[0] destroy() /* recursively destroy all progenies */ free PCB[q] deallocate the element q from the linked list Version 2 of the same process creation hierarchy uses no linked lists. Instead, each PCB contains the 4 integer fields parent, first_child, younger sibling, and older sibling, as described in the subsection "Avoiding linked lists". Assignment 1. Implement the two versions of the process creation hierarchy. 2. Assume that PCB[O] is the only currently existing process and write a test program that performs a series of process creations and destructions. Ex: cr[@] /* creates 1st child of PCB[@] at PCB[1]*/ cr[e] /* creates 2nd child of PCB[@] at PCB[2]*/ /* creates 1st child of PCB[2] at PCB[3] */ cr[e] /* creates 3rd child of PCB[@] at PCB[4] */ de[e] 1* destroys all descendents of PCB[@], which includes processes PCB[1] through PCB[4] */ 3. Run the test program repeatedly in a long loop using both versions and compare the running times to see how much time is saved in version 2, which avoids dynamic memory management. cr[2] 11.1 Two versions of the process creation hierarchy Project objective Compare the performance of process creation and destruction when implemented with and without linked lists. Description Version 1 of the process creation hierarchy uses linked lists to keep track of child processes as described in section "The process control block", subsection "The PCB data structure". For the purposes of performance evaluation, the PCBs are simplified as follows: All PCBs are implemented as an array of size n. Each process is referred to by the PCB index, O through n-1. Each PCB is a structure consisting of only the two fields: parent: a PCB index corresponding to the process's creator children: a pointer to a linked list, where each list element contains the PCB index of one child process The necessary functions are simplified as follows: create() represents the create function executed by process PCB[p]. The function creates a new child process PCB[] of process PCB[p] by performing the following tasks: allocate a free PCB[q] o record the parent's index, p, in PCB[c] initialize the list of children of PCB[] as empty o create a new link containing the child's index q and appends the link to the linked list of PCB[b] destroy(D) represents the destroy function executed by 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 on the linked list of children of PCB[0] destroy() /* recursively destroy all progenies */ free PCB[q] deallocate the element q from the linked list Version 2 of the same process creation hierarchy uses no linked lists. Instead, each PCB contains the 4 integer fields parent, first_child, younger sibling, and older sibling, as described in the subsection "Avoiding linked lists". Assignment 1. Implement the two versions of the process creation hierarchy. 2. Assume that PCB[O] is the only currently existing process and write a test program that performs a series of process creations and destructions. Ex: cr[@] /* creates 1st child of PCB[@] at PCB[1]*/ cr[e] /* creates 2nd child of PCB[@] at PCB[2]*/ /* creates 1st child of PCB[2] at PCB[3] */ cr[e] /* creates 3rd child of PCB[@] at PCB[4] */ de[e] 1* destroys all descendents of PCB[@], which includes processes PCB[1] through PCB[4] */ 3. Run the test program repeatedly in a long loop using both versions and compare the running times to see how much time is saved in version 2, which avoids dynamic memory management. cr[2]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started