Can someone answer the following code below in C++: Please add to the project a print statement that says how long each version ran in milliseconds please!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C++

Can someone answer the following code below in C++: Please add to the project a print statement that says how long each version ran in milliseconds please!

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, 0 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(p) represents the create function executed by process PCB[p]. The function creates a new child process PCB[q] of process PCB[p] by performing the following tasks:
    • allocate a free PCB[q]
    • record the parent's index, p, in PCB[q]
    • initialize the list of children of PCB[q] as empty
    • create a new link containing the child's index q and appends the link to the linked list of PCB[p]
  • destroy(p) 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 q on the linked list of children of PCB[p]
      • destroy(q) /* 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[0] is the only currently existing process and write a test program that performs a series of process creations and destructions. Ex:

cr[0] /* creates 1st child of PCB[0] at PCB[1]*/

cr[0] /* creates 2nd child of PCB[0] at PCB[2]*/

cr[2] /* creates 1st child of PCB[2] at PCB[3] */

cr[0] /* creates 3rd child of PCB[0] at PCB[4] */

de[0] /* destroys all descendents of PCB[0], which includes processes PCB[1] through PCB[4] */

  1. 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. 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education