Problem Statement: (The following problem is based on problem statements in a number of operating systems texts) For this lab, you'll be setting up 2 queues of PCBs. A process control block (PCB) is an internal structure that is used to hold information associated with a process. A process is an instance of a program that is brought into random-access memory (RAM) for execution. To simplify matters, you'll be setting up 2 queues: a ready queue and a wait queue and, PCBs each PCB will have 2 fields: a process ID or PID (a positive integer) a link field to point to the next PCB on a queue The ready queue will have the PCBs for the processes that will be run in a first-come, first-served fashion. The wait queue will have the PCBs for the processes that will be waiting for a resource in a first-come, first-served fashion. If the PCB at the head of the ready queue needs some resource (for example, I/O) then it will be removed from the ready queue and moved to the rear of the wait queue. This happens, when the user selects option #2 from the menu. Otherwise, the process at the head of the ready queue is to be executed (its PCB removed from the head of the ready queue). This happens, when the user selects option #3 from the menu. Assuming the resource need for the PCB at the head of the wait queue has been met, then it will be removed from the wait queue and moved to the rear of the ready queue. This happens, when the user selects option #1 from the menu. Set up a demo program, where you Set up the initial ready queue and wait queue Get PIDs from a data file or at the keyboard. Then, use a menu like the following to proceed: Utility Menu: 1.) Add a PCB to the Ready Queue 2.) Add a PCB to the Wait Queue 3.) Run a process 4.) Display all of the Processes 5.) Display the Ready Queue 6.) Display the Wait Queue 7.) Exit Please make a selection: Input Data: Repeatedly, enter one PID at a time at the keyboard alternatively, you may set up an input data file and get the data from the file If you place a PCB with this PID on the Wait Queue, then add the next PCB to the ReadyQueue That is, as PIDs are entered at the keyboard, populate the two queues in an alternate fashion Stop the inputting, when the user does not want to enter any additional PIDs Provide an appropriate option, each time that the above menu of options is presented to the user Processing: Set up: methods to initially populate the queues (used during the inputting) and the methods that will be called from within the above menu of options. Output Data: Prior to displaying contents of one or more queues, display an appropriate message to identify what is being displayed. Example 1: If option 5 is chosen from the above menu, then display a message like the following: The processes on the ready queue are: 876, 45, 1090, 231, 459 Example 2: If option 4 is chosen from the above menu, then display a message like the following: The processes on both queues are: 876, 45, 1090, 231, 459, 375, 802, 190, 621, 1023, 7643
Problem Statement:
(The following problem is based on problem statements in a number of
For this lab, you'll be setting up 2 queues of PCBs.
A process control block (PCB) is an internal structure that is used to hold information associated with a process.
A process is an instance of a
To simplify matters, you'll be setting up
- 2 queues:
- a ready queue and
- a wait queue
- and, PCBs
- each PCB will have 2 fields:
- a process ID or PID (a positive integer)
- a link field to point to the next PCB on a queue
- each PCB will have 2 fields:
The ready queue will have the PCBs for the processes that will be run in a first-come, first-served fashion.
The wait queue will have the PCBs for the processes that will be waiting for a resource in a first-come, first-served fashion.
If the PCB at the head of the ready queue needs some resource (for example, I/O) then it will be removed from the ready queue and moved to the rear of the wait queue. This happens, when the user selects option #2 from the menu.
Otherwise, the process at the head of the ready queue is to be executed (its PCB removed from the head of the ready queue). This happens, when the user selects option #3 from the menu.
Assuming the resource need for the PCB at the head of the wait queue has been met, then it will be removed from the wait queue and moved to the rear of the ready queue. This happens, when the user selects option #1 from the menu.
Set up a demo program, where you
- Set up the initial ready queue and wait queue
- Get PIDs from a data file or at the keyboard.
- Then, use a menu like the following to proceed:
Utility Menu:
1.) Add a PCB to the Ready Queue
2.) Add a PCB to the Wait Queue
3.) Run a process
4.) Display all of the Processes
5.) Display the Ready Queue
6.) Display the Wait Queue
7.) Exit
Please make a selection:
Input Data:
- Repeatedly, enter one PID at a time at the keyboard
-
- alternatively, you may set up an input data file and get the data from the file
- If you place a PCB with this PID on the Wait Queue, then add the next PCB to the ReadyQueue
- That is, as PIDs are entered at the keyboard, populate the two queues in an alternate fashion
-
- Stop the inputting, when the user does not want to enter any additional PIDs
- Provide an appropriate option, each time that the above menu of options is presented to the user
Processing:
Set up:
-
-
- methods to initially populate the queues (used during the inputting) and
- the methods that will be called from within the above menu of options.
-
Output Data:
Prior to displaying contents of one or more queues, display an appropriate message to identify what is being displayed.
Example 1:
If option 5 is chosen from the above menu, then display a message like the following:
The processes on the ready queue are:
876, 45, 1090, 231, 459
Example 2:
If option 4 is chosen from the above menu, then display a message like the following:
The processes on both queues are:
876, 45, 1090, 231, 459, 375, 802, 190, 621, 1023, 7643
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images