Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Process Concept, States and PCB

Lesson 9 of 31 in the free Operating System & Linux Programming notes on Siksha Sarovar, written by Rohit Jangra.

What is a Process?

A process is a program in execution. A program is a passive entity (a file on disk); a process is an active entity with a program counter, register state, stack, heap, and a set of resources (open files, memory).

A process consists of:

  • Text section — the executable code.
  • Data section — global and static variables.
  • Heap — dynamically allocated memory.
  • Stack — function activation records.
  • Program counter & CPU registers.

Process States

StateMeaning
NewProcess is being created.
ReadyWaiting for the CPU.
RunningInstructions are executing.
Waiting / BlockedWaiting for an event (I/O, signal).
TerminatedFinished or killed; resources being reclaimed.

Process Control Block (PCB)

The PCB is the kernel data structure that represents a process. In Linux it is struct task_struct.

Fields stored in the PCB:

  • Process identification — PID, PPID, UID, GID.
  • Process state — new, ready, running, waiting, terminated.
  • Program counter — address of the next instruction.
  • CPU registers — saved on context switch.
  • CPU scheduling info — priority, scheduling queue pointers.
  • Memory management — page tables, base/limit registers.
  • Accounting — CPU time, time limits.
  • I/O status — open files, allocated devices.

Context Switch

When the OS switches the CPU from one process to another it must:

  1. Save the current process's registers and program counter into its PCB.
  2. Update the previous process's state.
  3. Load the new process's PCB state into the CPU.

Context switches are pure overhead — no user work is done — so the OS aims to keep them short.

Process Scheduling Queues

  • Job queue — all processes in the system.
  • Ready queue — processes ready to run, in main memory.
  • Device queues — processes waiting on a particular I/O device.

Schedulers

  • Long-term (job) scheduler — selects which jobs to bring into the ready queue. Controls degree of multiprogramming.
  • Short-term (CPU) scheduler — picks the next process to run. Invoked very frequently.
  • Medium-term scheduler — swaps processes in/out of memory to relieve memory pressure.

Summary

  • A process = program + execution state + resources.
  • Five canonical states; transitions are driven by the OS or by I/O events.
  • The PCB stores everything needed to suspend and later resume a process.