Resources | Subject Notes | Computer Science
An Operating System (OS) is a fundamental piece of software that manages computer hardware and software resources. It provides a platform for applications to run and acts as an intermediary between the user and the hardware. This section focuses on the purpose of an OS, with a particular emphasis on process management.
Operating systems serve several crucial purposes. These can be broadly categorized as:
Process management is a critical aspect of operating system functionality. A process is a program in execution. It represents an instance of a program that is being actively carried out by the CPU.
A process typically goes through several stages during its lifecycle:
The different states a process can be in are crucial for the OS to manage them effectively. These states are often represented in a process control block (PCB), which is a data structure maintained by the OS for each process.
A PCB contains all the necessary information about a process, including:
Field | Description |
---|---|
Process ID (PID) | A unique identifier for the process. |
Process State | The current state of the process (e.g., Ready, Running, Blocked). |
Program Counter (PC) | Indicates the address of the next instruction to be executed. |
CPU Registers | The values of the CPU registers at the time the process was last executed. |
Memory Management Information | Details about the memory allocated to the process. |
Accounting Information | Information used for billing and resource tracking. |
Process Control Block (PCB) Priority | The priority of the process relative to other processes. |
Process scheduling is the process of selecting which process to run next. The OS uses various scheduling algorithms to make these decisions. Common scheduling algorithms include:
The choice of scheduling algorithm significantly impacts system performance, affecting metrics like turnaround time, waiting time, and throughput.
Context switching is the process of saving the state of the current process and loading the state of the next process to be executed. This allows the OS to switch between multiple processes, giving the illusion of parallel execution. Context switching involves saving the contents of the CPU registers, the program counter, and other relevant information into the PCB.
Efficient context switching is crucial for maximizing CPU utilization and responsiveness of the operating system.