Chapter 2 3 min read
Save

Process Management

Operating System · BCA · Updated Apr 15, 2026

Table of Contents

What is a Process?

A process is a program in execution. Unlike a static program, a process has a memory image, CPU registers, program counter, and a set of open resources. The OS keeps track of every running process.

Process Control Block (PCB)

The PCB is a data structure the OS maintains for each process. Typical fields:

  • Process ID (PID) and parent PID.
  • Process state.
  • Program counter.
  • CPU registers.
  • Memory management info (base, limit, page table).
  • Accounting info (CPU usage, start time).
  • I/O status (open files, devices).
  • Scheduling info (priority, queue pointers).

Process States

Five classic states:

  1. New — being created.
  2. Ready — waiting for CPU.
  3. Running — executing on CPU.
  4. Blocked (Waiting) — waiting for I/O or event.
  5. Terminated — finished.

Transitions:

  • new → ready: admit
  • ready → running: scheduler dispatch
  • running → ready: timer interrupt
  • running → blocked: I/O request
  • blocked → ready: I/O complete
  • running → terminated: exit

Context Switch

When the scheduler switches CPUs from one process to another, it must:

  1. Save current process state (registers, PC) into its PCB.
  2. Load the next process's state from its PCB.
  3. Update memory mappings.

Context switches are pure overhead (no user work happens), so a fast implementation matters.

Process vs Program vs Thread

  • Program — passive file on disk.
  • Process — active instance with its own address space.
  • Thread — lightweight unit of execution sharing an address space with sibling threads.

Process Creation

In UNIX, fork() creates a copy of the current process; exec() replaces the copy's memory with a new program. Windows uses CreateProcess() which combines the two.

pid_t p = fork();
if (p == 0) { execlp("ls", "ls", NULL); }
else { wait(NULL); }

Process Termination

A process calls exit(status). Its resources are released; its exit status is kept until the parent calls wait(). Processes whose parent has died become orphans and are inherited by init.

Process Scheduling Queues

  • Job queue — all processes in the system.
  • Ready queue — processes ready to run.
  • Device queues — one per I/O device.

Schedulers

  • Long-term scheduler (job scheduler) — admits new processes.
  • Short-term scheduler (CPU scheduler) — picks next ready process.
  • Medium-term scheduler — swaps processes to/from disk (in older systems).

Inter-Process Communication (IPC)

Processes with separate address spaces communicate through:

  • Shared memory — fastest; needs synchronization.
  • Message passingsend()/receive() primitives.
  • Pipes (anonymous and named) — byte streams.
  • Sockets — local or network endpoints.
  • Signals — notifications (SIGINT, SIGKILL, SIGUSR1).

Cooperating vs Independent Processes

Processes may share data and affect each other (cooperating) or be independent. Cooperation improves performance, modularity, and code reuse but requires synchronization.

Summary

The process is the fundamental unit of work in an OS. Understanding process states, PCBs, context switching, creation, and IPC is the foundation for everything else in OS design.

Important Questions

  1. Define process. Differentiate process and program.
  2. What is a PCB? List its fields.
  3. Draw the five-state process diagram with transitions.
  4. What is a context switch?
  5. Differentiate process and thread.
  6. Explain fork() and exec() in UNIX.
  7. List the types of schedulers.
  8. List five IPC mechanisms with examples.

Related Notes

Discussion

0 comments

Join the discussion

Log in to share your thoughts and help fellow students.

Log in to comment

No comments yet. Be the first to share your thoughts!