CS Atlas GATE 2027
Operating Systems course
0 / 58 complete

Operating Systems/Phase 1 · Processes & Threads

Lesson 1.1.1 · Item 6 of 58

Processes: memory layout, process control block and process states

Read at your own pace. Try the questions before opening the answers.

On this page

0 · Recall Warm-up

Answer from memory first. Answers are in the Answer Vault at the bottom.

  1. One system call causes how many mode switches? from Lesson 0.1.3
  2. What does the timer interrupt let the OS do? from Lesson 0.1.2
  3. Program vs process? from Lesson 0.1.1

1 · The Hook

Open a browser, a music player and a terminal: three processes. Only one can use a single CPU at any instant, so at every moment most of them are waiting for something: the CPU, a key press, a disk read. The OS tracks each one with a record card and moves it between a handful of states. GATE asks which state changes are possible and what the record card holds.

2 · Predict First

Try the questions first. Open when you are ready to check.

A process asks to read a file from disk. Reading takes a long time compared with the CPU. Should the process keep the CPU while it waits?

Make a guess in your head. The answer opens Section 3.

3 · Core Concept

Predict First — the answer

No. It moves to a waiting (blocked) state and the CPU is given to another process. When the disk finishes, the process becomes ready again and waits for its turn on the CPU.

In plain words

A process is a running program with its own memory area. The OS keeps a process control block (PCB), a record card with everything needed to pause and resume it. A process is always in one state: just created, ready to run, running, waiting for something, or finished.

1. A process in memory

RegionHoldsGrows
Text (code)the program's instructionsfixed
Dataglobal and static variablesfixed
Heapmemory allocated at run time (malloc, new)upwards
Stackfunction calls: local variables, parameters, return addressesdownwards

2. The process control block (PCB)

One per process, kept by the kernel: process ID (PID), state, program counter (next instruction), CPU registers, scheduling information (priority), memory-management information (page table), list of open files, accounting information. Saving and loading PCBs is how the OS pauses and resumes processes.

3. The five states

StateMeaning
Newbeing created
Readycould run; waiting only for the CPU
Runninginstructions are executing on the CPU
Waiting (blocked)waiting for an event: I/O completion, a signal, a resource
Terminatedfinished

4. The transitions

From → ToCause
New → Readyadmitted by the OS
Ready → Runningdispatched by the scheduler
Running → Readypre-empted (timer interrupt, a higher-priority process arrives)
Running → Waitingrequests I/O or waits for an event
Waiting → Readythe event happens (I/O finishes)
Running → Terminatedexit

Impossible directly: Waiting → Running (it must go through Ready), Ready → Waiting (it is not running, so it cannot request anything), New → Running.

5. Suspended states

When memory is short, the OS can swap a process out to disk: Ready → Suspended-ready and Waiting → Suspended-waiting (handled by the medium-term scheduler, Lesson 1.1.2). Suspended-waiting becomes Suspended-ready when its event happens; swapping back in returns it to Ready.

4 · Visual

The five-state model. There is no arrow from Waiting straight to Running, nor from Ready to Waiting.

A process's memory (high addresses at the top)

 +-----------+
 |   stack   |  local variables, return addresses   (grows down)
 |     |     |
 |     v     |
 |           |
 |     ^     |
 |     |     |
 |   heap    |  malloc / new                         (grows up)
 +-----------+
 |   data    |  globals, statics
 +-----------+
 |   text    |  machine code
 +-----------+

5 · Worked Examples

Example 1 Easy

A running process's time slice ends. Which state does it move to?

Solution

Ready (pre-empted).

Example 2 Medium

Where does a local variable of a function live: data, heap or stack?

Solution

Stack.

Example 3 GATE

Which transition is NOT possible in the five-state model: Running → Waiting, Waiting → Ready, Waiting → Running, Ready → Running?

Solution

Waiting → Running: a woken process must first become Ready.

6 · GATE Traps

  • Waiting → Running directly is impossible; so is Ready → Waiting.
  • Pre-emption sends Running → Ready, not Waiting.
  • Globals are in data, malloc'd memory in the heap, locals on the stack.
  • The PCB is kept by the kernel, not inside the process's own memory.

7 · Memory Hook

"Ready waits for the CPU; Waiting waits for an event."

8 · Connect the Dots

Processes have to come from somewhere. Next lesson creates them with fork(), a GATE favourite for counting questions, and meets the schedulers that move processes between states.

9 · Self-Test

GATE format. Try every question before opening the vault.

Q1 · MCQ · 1 mark(s) — Transitions

Which state transition is impossible?

  1. (A) Ready → Running
  2. (B) Waiting → Running
  3. (C) Running → Waiting
  4. (D) Running → Ready

Q2 · MCQ · 1 mark(s) — Cause

A process in the Waiting state moves to Ready when:

  1. (A) the event it was waiting for occurs
  2. (B) the scheduler dispatches it
  3. (C) it calls exit
  4. (D) its time slice ends

Q3 · MSQ · 2 mark(s) — PCB

Which items are stored in a process control block?

  1. (A) Program counter
  2. (B) List of open files
  3. (C) CPU register values
  4. (D) The source code of the program

Q4 · MCQ · 1 mark(s) — Memory layout

Memory obtained with malloc comes from the:

  1. (A) data segment
  2. (B) stack
  3. (C) text segment
  4. (D) heap

Q5 · MCQ · 1 mark(s) — Suspension

Memory is short, so the OS swaps a Waiting process out to disk. Its new state is:

  1. (A) Ready
  2. (B) Terminated
  3. (C) Suspended-waiting
  4. (D) Running

10 · Rule Card

  • Process memory: text (code), data (globals), heap (dynamic, grows up), stack (calls, grows down).
  • PCB: PID, state, program counter, registers, scheduling info, memory info, open files, accounting.
  • States: New, Ready, Running, Waiting, Terminated.
  • Transitions: admit, dispatch (Ready→Running), pre-empt (Running→Ready), I/O request (Running→Waiting), event done (Waiting→Ready), exit. Waiting→Running and Ready→Waiting are impossible.
  • Suspended-ready / suspended-waiting via swapping.

11 · Concept Ledger

Unlocked in this lesson. From here on, these terms may be used.

processtext, data, heap and stack segmentsprocess control blockprocess IDprogram counterprocess statesdispatchpre-emptionblocking on I/Oimpossible transitionssuspended statesswapping

12 · Answer Vault

Try the questions first. Open when you are ready to check.

🔐 Open the Answer Vault

Recall Warm-up

  1. Take the CPU back from a running process.
  2. A process is a program in execution.

Self-Test

Q1 Answer: (B) · 1 mark(s)

A woken process goes to Ready first.

  • (A) is wrong: Dispatch.
  • (C) is wrong: I/O request.
  • (D) is wrong: Pre-emption.

Re-read: Lesson 1.1.1 — Processes: memory layout, process control block and process states

Q2 Answer: (A) · 1 mark(s)

I/O completion or a signal.

  • (B) is wrong: That moves Ready → Running.
  • (C) is wrong: That ends the process.
  • (D) is wrong: That moves Running → Ready.

Re-read: Lesson 1.1.1 — Processes: memory layout, process control block and process states

Q3 Answer: (A) (B) (C) · 2 mark(s)

Code is in memory/disk, not the PCB.

  • (D) is wrong: Not part of the PCB.

Re-read: Lesson 1.1.1 — Processes: memory layout, process control block and process states

Q4 Answer: (D) · 1 mark(s)

Run-time allocation.

  • (A) is wrong: Globals and statics.
  • (B) is wrong: Locals and call frames.
  • (C) is wrong: Code only.

Re-read: Lesson 1.1.1 — Processes: memory layout, process control block and process states

Q5 Answer: (C) · 1 mark(s)

Swapped out while still waiting for its event.

  • (A) is wrong: Its event has not happened.
  • (B) is wrong: It has not finished.
  • (D) is wrong: It is not on the CPU.

Re-read: Lesson 1.1.1 — Processes: memory layout, process control block and process states

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.