Question: Watch the walkthrough video, introducing you to the code skeleton that I have provided. Part 2 - Add to the process handling This assignment is

 Watch the walkthrough video, introducing you to the code skeleton that

Watch the walkthrough video, introducing you to the code skeleton that I have provided. Part 2 - Add to the process handling This assignment is all about Processes. We need a data structure to hold our process data. Look at the class called "PCB it is an innerested class to Kernel O). Inside the PCB, we will want a byte array of some size (defined in the HAL as a constant) for the contents of the registers. The PCB should hold an integer which is the process id (PID). PCB is just a data structure and has no methods. The kernel needs to keep a data structure of all of the active PCBs; create this. The kernel already has a reference to the current PCB. We need three new methods for processes: CreateProcess: should take a Callable as a parameter and return an int (PID). The PID you can generate as an incremented number (1,2,3,4, etc). Create a new PCB. Set the PID. Allocate space for the registers. Set the Callable for the PCB to be the Callable that is passed in as a parameter. Add the PCB to the active PCB list. Reschedule: Takes no parameters and returns nothing. This is called when it is time to switch running processes. This should call StoreProgramData() to save the registers (pretend). Then it should "pick a new process to run. For now, take the first PCB in the active list and put it in current. We will improve the algorithm in the next assignment. Finally, we should call RestoreProgramData() to fill the registers (pretend). DeleteProcess: takes a PID as a parameter. Find the PCB for this PID. Remove it if you find it. Java will, of course, garbage dispose the object; in C we would have to deal with that ourselves. Call Reschedule() if the current process is deleting itself. Change Exit() to call DeleteProcess. Part 3 - Test It Out In main(), you will need to instantiate a kernel. Call Init, passing a method that you write (lambda or classes) that will create 4 processes. Each process should print Process X (X = 1 - 4) using the system call, then call Exit. You must submit buildable.java files for credit. Rubric Comments Poor None/Excessive (0) OK Good Great "What" not "Why", few Some "what" comments Anything not obvious (5) or missing some (7) has reasoning (10) Lots of abbreviations Full words most of the Full words, descriptive (5) time (8) (10) Single letters everywhere (0) Variable/Function naming Kernel Changes None (0 None (0) Create Processs - Setup Create Process Runnable DeleteProcess None (0) Either has a data Gas a data structure for structure for holding holding PCBs and has a PCBs or has a PID PID counter (10) counter (5) Creates PCB (5) Creates PCB, either sets Creates PCB, both sets the PID or allocates the PID and allocates register space (10) register space (15) Sets callable OR adds to Sets callable and adds to active list (5) active list (10) Calls reschedule Removes PCB from Both reschedules and appropriately(5) active list (10) removes PCB(15) Calls Store/Restore(5) Sets up next process(5) Callsstore/restore AND sets up next process (10) Attempted (10) Creates and runs all 4 processes, printing messages (20) None (0) Reschedule None (0) Test Program None (0) Watch the walkthrough video, introducing you to the code skeleton that I have provided. Part 2 - Add to the process handling This assignment is all about Processes. We need a data structure to hold our process data. Look at the class called "PCB it is an innerested class to Kernel O). Inside the PCB, we will want a byte array of some size (defined in the HAL as a constant) for the contents of the registers. The PCB should hold an integer which is the process id (PID). PCB is just a data structure and has no methods. The kernel needs to keep a data structure of all of the active PCBs; create this. The kernel already has a reference to the current PCB. We need three new methods for processes: CreateProcess: should take a Callable as a parameter and return an int (PID). The PID you can generate as an incremented number (1,2,3,4, etc). Create a new PCB. Set the PID. Allocate space for the registers. Set the Callable for the PCB to be the Callable that is passed in as a parameter. Add the PCB to the active PCB list. Reschedule: Takes no parameters and returns nothing. This is called when it is time to switch running processes. This should call StoreProgramData() to save the registers (pretend). Then it should "pick a new process to run. For now, take the first PCB in the active list and put it in current. We will improve the algorithm in the next assignment. Finally, we should call RestoreProgramData() to fill the registers (pretend). DeleteProcess: takes a PID as a parameter. Find the PCB for this PID. Remove it if you find it. Java will, of course, garbage dispose the object; in C we would have to deal with that ourselves. Call Reschedule() if the current process is deleting itself. Change Exit() to call DeleteProcess. Part 3 - Test It Out In main(), you will need to instantiate a kernel. Call Init, passing a method that you write (lambda or classes) that will create 4 processes. Each process should print Process X (X = 1 - 4) using the system call, then call Exit. You must submit buildable.java files for credit. Rubric Comments Poor None/Excessive (0) OK Good Great "What" not "Why", few Some "what" comments Anything not obvious (5) or missing some (7) has reasoning (10) Lots of abbreviations Full words most of the Full words, descriptive (5) time (8) (10) Single letters everywhere (0) Variable/Function naming Kernel Changes None (0 None (0) Create Processs - Setup Create Process Runnable DeleteProcess None (0) Either has a data Gas a data structure for structure for holding holding PCBs and has a PCBs or has a PID PID counter (10) counter (5) Creates PCB (5) Creates PCB, either sets Creates PCB, both sets the PID or allocates the PID and allocates register space (10) register space (15) Sets callable OR adds to Sets callable and adds to active list (5) active list (10) Calls reschedule Removes PCB from Both reschedules and appropriately(5) active list (10) removes PCB(15) Calls Store/Restore(5) Sets up next process(5) Callsstore/restore AND sets up next process (10) Attempted (10) Creates and runs all 4 processes, printing messages (20) None (0) Reschedule None (0) Test Program None (0)

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!