CPU_state – When the process is stopped, the current state of the CPU, consisting of various hardware registers and flags, is saved in this field to be reloaded when the process resumes.
PCB Data | Description | Data Stored As | Can Change |
---|---|---|---|
process_state | This is the state of the process, running, ready, or blocked most often. | Integer | Yes |
memory | the section of memory that is defined for the process | Pointers | Yes |
scheduling_information | Contains information used by the scheduler to decide when the process should run next. The information typically records the process’s CPU time (how much time it has spent in the system), the real time in the system (non-running time as well as running time), the priority (can give an idea for how long the process will run, and when it should run – this may be modifiable by a system admin), and any possible deadlines if supported by the OS. | Integers | Yes |
open_files | which files are currently open by the process. | Start of Linked List | Yes |
other_resources | other resources (non-files) that are needing to be tracked, like a printer, scanner, network access, etc. | Start of Linked List | Yes |
parent | was this process spawned by another. If so we need to track it. There can only be on parent. | Pointer/Index to PCB | No |
children | did this process spawn other processes, if so we need to track them. This field may change as new processes are started, and end. | Start of Linked List (to other PCB) | Yes |
Notice that there are several linked lists that are used. Linked lists are slow to navigate and require dynamic memory management.
One solution is to use what Linux does which is allow pointers to the next and previous children of the list items – so that its faster to navigate back and forth through the list, the down side is it takes a little more memory. However, given the number of PCBs vs the time spent switching tasks, the trade off is considered more than worth it.
Managing PCBs
The OS needs a minimum of two lists to manage PCBs. A waiting list, which is associated with the resources being blocked, and the ready list.
The ready list may be thought of as a priority queue, and every item in this list is ready to be run by the CPU.
Now the ready list could be a simple linked list if it doesn’t have any priorities associated with it, or it could be designed in such a way, that priority items run up the list till it is ready to be processed.
You could have PCBs point to the next PCB on the list, to simplify the linked list process if you want.
Parts of the PCB was originally found on Access 2 Learn