Process Management in Operating System
Subject: Computer Science Fundamentals · Language: Operating System · Level: beginner · 9 min read
Learn process management with clear explanation of program vs process, process states, PCB, context switching, scheduling, and process lifecycle.
Process management is one of the most important functions of an operating system. A computer may run many programs at the same time, but the CPU and memory are limited. The operating system manages these running programs so that the system remains efficient, fair, and stable. A process is a program in execution. This is a very important definition. A program stored on disk is not a process yet. It becomes a process only when it is loaded into memory and starts running. For example, the browser installed on your computer is a program. When you double-click it and it starts running, the operating system creates a browser process. If you open a music player, that becomes another process.
Program vs Process
A program is passive. It is a file or set of instructions stored on disk. It does not use CPU until it is executed. A process is active. It is a running instance of a program with allocated memory, CPU state, and system resources.
The same program can have multiple processes. For example, you may open two separate windows of the same application. The OS may treat them as separate processes or create multiple child processes depending on the application design. A program contains code, but a process contains code plus execution state. This state includes current instruction, registers, memory area, open files, and other runtime information.
Why Process Management Is Needed
Process management is needed because many processes may compete for CPU, memory, files, and input-output devices. Without proper management, one process could use too many resources, another process could starve, or the system could become unresponsive. The OS creates processes, schedules them, switches between them, pauses them, resumes them, and terminates them. It also protects processes from interfering with each other. For example, if a video player, browser, text editor, and antivirus are running at the same time, the OS must manage all of them. It decides which process gets CPU time and keeps track of each process state.
Process States
A process does not stay in one condition throughout its lifetime. It moves through different states. The common process states are new, ready, running, waiting, and terminated. The new state means the process is being created. The operating system is preparing required data structures and resources for it.
The ready state means the process is ready to run but waiting for CPU. It has everything needed except CPU time. Ready processes are usually kept in the ready queue. The running state means the process is currently being executed by the CPU. On a single-core CPU, only one process can be running at a time, though switching is very fast.
The waiting or blocked state means the process cannot continue until some event happens. For example, it may be waiting for disk input, keyboard input, network data, or completion of an input-output operation. The terminated state means the process has completed or has been stopped. The OS releases its resources after termination.
Process State Transitions
A process enters the ready state after it is created. When the scheduler selects it, it moves from ready to running. If its time slice expires, it may move back from running to ready. If a running process requests input-output, it may move to the waiting state. When the input-output completes, it moves back to ready. When the process finishes execution, it moves to terminated. These transitions help the OS manage CPU efficiently. A process waiting for input-output should not waste CPU time. Another ready process can use the CPU during that wait.
Process Control Block
The Process Control Block, or PCB, is a data structure maintained by the operating system for each process. It stores all important information needed to manage that process. The PCB contains process ID, process state, program counter, CPU registers, scheduling information, memory information, accounting information, and information about open files and devices. The process ID uniquely identifies a process. The process state tells whether it is ready, running, waiting, or terminated. The program counter stores the address of the next instruction to execute. CPU registers store temporary execution values.
Memory information tells which memory area belongs to the process. Scheduling information helps the OS decide when the process should run. File information tells which files are currently opened by the process. The PCB is extremely important because the OS uses it during context switching. Without the PCB, the OS could not pause and resume processes correctly.
Context Switching
Context switching means stopping one process and starting another process on the CPU. The OS saves the current process state and loads the state of the next process. Suppose process A is running and the OS decides to run process B. The OS saves process A's program counter, registers, and other state information in its PCB. Then it loads process B's saved state from process B's PCB and gives CPU control to process B.
Context switching allows multitasking. It creates the feeling that many programs are running at the same time. However, context switching itself takes time. During switching, the CPU is not doing actual user program work. Because of this, too many context switches can reduce performance. A good OS tries to balance responsiveness and efficiency.
Process Scheduling
Process scheduling decides which ready process should run next. The scheduler looks at ready processes and selects one based on a scheduling algorithm. Different scheduling algorithms have different goals. Some try to reduce waiting time. Some try to improve response time. Some try to give fair CPU time to all processes. Scheduling is studied separately because it is a major part of process management.
Parent and Child Processes
A process can create another process. The creator is called the parent process, and the new process is called the child process. This relationship is common in operating systems. For example, a command-line shell may create a child process when you run a command. The shell remains the parent, and the command runs as a child process. Parent-child process relationships help organize process execution. They also help with communication, waiting, and resource management.
Independent and Cooperating Processes
An independent process does not affect or depend on other processes. It works separately and does not share data with other processes. A cooperating process can affect or be affected by another process. Cooperating processes may share data, communicate, or work together on a task. For example, one process may produce data and another process may consume it. Cooperating processes need proper communication and synchronization. Otherwise, shared data may become inconsistent.
Process Creation and Termination
When a process is created, the OS assigns it a process ID, allocates memory, initializes its PCB, loads the program code, and places it in the ready queue. After that, the scheduler may select it for execution. A process may terminate normally after completing its work. It may also terminate because of an error, user action, or OS decision. After termination, the OS releases memory, closes files, updates process tables, and removes the process from scheduling.
Example of Process Management in Daily Use
Imagine you are writing notes while music is playing and a browser is downloading a file. The notes app, music player, browser, and download task may all be separate processes or threads. The OS schedules them, manages their memory, handles disk and network input-output, and keeps the system responsive. If the browser waits for network data, the CPU can run the notes app or music player. If the music player needs audio output, the OS coordinates with the audio device. This coordination is part of process and resource management.
Summary
Process management is the OS function that handles running programs. It includes process creation, process states, scheduling, context switching, process termination, and maintaining process information through the PCB. A beginner should clearly understand that a program is stored code, while a process is running code. Once this difference is clear, topics like scheduling, threads, synchronization, and deadlock become easier to understand.
Process Management in Real Execution
When many applications are open, the OS continuously creates, pauses, resumes, and terminates processes. It also tracks each process using information such as process ID, state, priority, memory location, open files, and CPU register values. This tracking allows the OS to switch between processes without losing their progress. A browser tab, code editor, music player, and terminal can all appear to run together because the OS manages process execution quickly and repeatedly.
Why Process Information Is Stored
The OS stores process information so it can stop a process and later continue it from the same point. This information is kept in a structure commonly called the Process Control Block. Without this saved information, multitasking would not work correctly. Every time the CPU moved away from a process, the process would lose its place. The PCB prevents that by preserving the process context.
More Operating System Lessons
- Introduction to Operating System
- Types of Operating System
- Operating System Functions and Services
- System Calls in Operating System
- Process Scheduling in Operating System
- CPU Scheduling Algorithms
- Threads and Multithreading in Operating System
- Process Synchronization in Operating System
- Deadlock in Operating System
- Memory Management in Operating System
- Virtual Memory in Operating System
- File System in Operating System