Assignment 1
Assignment 1
PREPARED FOR:
DR. ABDUL AZIZ K ABDUL HAMID
PREPARED BY:
AMAL HAZIRAH BINTI SAIFUDDIN (S67202)
Introduction
All processes are equipped with information and execution instructions. These instructions
may involve executing a code or specifying devices for interaction during the process
execution. Hence, a data structure called a process Control block (PCB) is required to store
comprehensive information about a process.
Definition
A data structure can generate to hold the process’s information when the operating system
creates a process. It’s referred to as Process Control Block(PCB). PCB is a data structure
utilized to store information related to a process and PCB are stored in a dedicated memory
called kernel space reserved for the operating system.
Each process has it own unique PCB , which contains various attributes such as process ID,
priority, registerd, program counters, process states and a list of open files , etc.
Diagram 1.0
Role of PCB
Operating system is responsible for allocating a CPU to a process since a process does not
reuqire continuos CPU usage. For example , an input/output process; the CPU is only utilized
when the process is triggered.
The process control block serves as an identification card for each process. The operating
system cannot identify individual processes until it consults are PCB associated with each
process until it consults the PCB associated with each process.
For instance , there are currently multiple processes running on the CPU, including MS
Word, PDF handling and printing.
This is where the PCB comes into play as a data structure used to store information about
each process.Whenever a user initiates a process, such as a print command, the operating
system creates a PCB specificially for that process. The PCB is then utilized by the operating
system to execute and manage processes when the operating system has available resources.
PCB Structure
Process ID
Process State
Process priority
Accounting information
Program counters
CPU registers
PCB pointers
List of open files
Process I/O ststus information
Diagram 2.0
During execution , the Operating System has the ability to manipulate information within the
PCB. For example, the Operating System intends to change the current state of the PCB from
ist currently running state to another state. This can be achieved by modifying the current
pointer( current process_state = new_state).
In order to maximize the multiprogramming and prevent CPU idlenees, the Operating System
employs rapid switching between multiple processes to keep the CPU occupied. The PCB
serves as reliable sorce of information about each repective process in this context.
Let’s say a scenario where the operating System suspends the current process, P1. This
entails manipulating the PCB of the current process. The necessary details od the processor
registers for the ongoing process execution are saved on the stack , and a reference to that
stack frame is stored in the PCB. Cosquently, the CPU becomes available for other processes
that are ready to execute. For example , Process P2 begins execution , and the operating
system updates the current point to the PCB of P2.
The operating system intends to loas process P1 back into the CPU , it utilizes the Process
table to locate the corresponding PCB of P1 . The operating system then locates the
associated stack frame where all the details of the processor registers are stored this
information enables the Operating System to restore the necessary hardware state required for
the execution of Process P1.
Conclusion
The PCB is a data structure used by the operating system to manage and execute processes. It
stores important information about each process , such as process ID, priority, state and
resourse usage.
The PCB allows the operating system to assign CPU to processes and switch between them
rapidly to efficient multitasking. It serves as a source of truth about each process and helps
the operating system manage process execution.
When a process is suspended, its details are saved in the PCB, including processor registers,
and the CPU is made available for other processes. The operating system can easily retrieve
and restore the saved information when the process needs to resume execution.
Overall, the PCB is essential for process management , enabling the operating system to
efficientyly handle processes , allocate resources and ensure optimal CPU utilization.