Starting from:

$30

CSCI 340 Project Solved

Process Creation Assignment Project objective: 

Compare the performance of process creation and destruction when implemented with and without linked lists.

 

Overview: 

 

Method 1 of the process creation hierarchy uses linked lists to keep track of child processes as described in section 5.1 (within Week 5 – Class 9 and 10) The process control block, subsection The PCB data structure.

 

For the purposes of performance evaluation, the PCBs are simplified as follows:

a.     Implementation of the table of all the PCBs is an array of size n.

b.     Each process is referred to by a PCB index, 0 through n-1.

c.     Each PCB is a structure consisting of only the two fields:

1.     Parent: a PCB index corresponding to the process's creator.

2.     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:

a.     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:

1.     Allocate a free PCB[q].

2.     Record the parent's index, p, in PCB[q].

3.     Initialize the list of children of PCB[q] as empty.

4.     Create a new link containing the child's index q and appending the link to the linked list of PCB[p].

b.     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]:

1.     Destroy(q). /* recursively destroy all descendants. */

2.     Free PCB[q].

3.     Deallocate the element q from the linked list.

 

Method 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.

 

             

Design: 

 

1.     Implement the two methods of the process creation hierarchy in Java.

 

2.     Assume that PCB[0] is the only currently existing process and write a test procedure that performs a series of process creations and destructions.  For example:  

Create(0)   /* creates 1st child of PCB[0] at PCB[1]*/

Create(0)   /* creates 2nd child of PCB[0] at PCB[2]*/

Create(2)   /* creates 1st child of PCB[2] at PCB[3] */

Create(0)   /* creates 3rd child of PCB[0] at PCB[4] */

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

 

3.     The test procedure should do a significant number of process creations and deletions with the calls to create and destroy intermingled

 

4.     Run the test procedure repeatedly in a long loop on each method, with the test procedure computing and then printing the running time for the method.  This should show how much time method 2 saves, which avoids dynamic memory management.

 

5.     One or more classes implement the test procedure and the two methods.

 

6.     Create a driver class and make the name of the driver class Assignment1 containing only one method: public static void main(String args[]).

The main method essentially executes the test procedure on each method.

 

I compile and run your program via the command line using the Java JDK.  Therefore, the command I type to execute your program is java Assignment1.  Make sure your project compiles and runs via the command line using the Java JDK.  I will not use any other Java development tool to compile and run your project code.

 

7.     You must declare public each class you create which means you define each class in its own file.

 

8.     You must declare private all the data members in every class you create.

 

9.     Tip: Make your program as modular as possible, not placing all your code in one .java file.  You can create as many classes as you need in addition to the classes described above.  Methods being reasonably small follow the guidance that "A function does one thing and does it well."  You will lose a lot of points for code readability if you do not make your program as modular as possible.  But, do not go overboard on creating classes and methods.  Your common sense guides your creation of classes and methods.

 

10.  Do NOT use your own packages in your program.  If you see the keyword package on the top line of any of your .java files then you created a package.  Create every .java file in the src folder of your Eclipse project, if you’re using Eclipse.

 

11.  Do NOT use any graphical user interface code in your program!

 

12.  Do NOT type any comments in your program.  If you do a good job of programming by following the advice in number 9 above then it will be easy for me to determine the task of your code.

 

             

More products