The OS has to track resources so that it knows when those resources are available for use. If it “just let” processes use resources, they could step on the resources and crash the system as a resource can only be used by a single process at a time.
So the OS uses an Resource Control Block (RCB), which is similar to a PCB.
RCB field | Explanation |
---|---|
resource_description | Contains the description of the resource’s properties and capabilities. |
state | Shows the current availability of the resource. If the resource is a single-unit resource then this field indicates whether it is currently free or allocated to some process. If the resource has multiple identical units, such as a pool of identical buffers, then this field keeps track of how many units are currently free and how many are allocated. |
waiting_list | When a process requests a resource and the resource is currently unavailable then the process’s PCB is removed from the ready list and added to the resource’s waiting list. The process is moved back to the ready list when resource becomes available and is allocated to the process. This is typically a linked list of PCBs. |
When a process request a resource the OS checks the state. To do so, the process must be in a running state.
A resource is allocated to a process if the process has access to and is able to utilize the resource. A resource is free if the resource may be allocated to a requesting process. These states are typically shown as an integer.
When a resource is done being used, it is released. This changes the state from allocated to free, and the system can then check the waiting list to see if there is a blocked process that can now access the resource. If so, it can be assigned to the process when it is ready to be run.
The scheduler function determines which process should run next and starts the process. The scheduler function is called at the end of each of the process a resource management functions: create, destroy, request, release.
System Resources was originally found on Access 2 Learn