CS Atlas GATE 2027
Operating Systems course
0 / 58 complete

Operating Systems/Phase 1 · Processes & Threads

Chapter review LI-1.1 · Item 8 of 58

Chapter 1.1 Lock-in

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

On this page

Phase 1Ch 1.1 Processes

ACompressed recap

Process = text, data, heap, stack + PCB (PID, state, PC, registers, open files). States New, Ready, Running, Waiting, Terminated; no Waiting → Running or Ready → Waiting. fork: 0 to child, PID to parent, copied memory; 2ⁿ processes from n forks; loops add per iteration. Zombie, orphan; context switch overhead; long/short/medium-term schedulers.

BMerged rule card

1.1.1 Processes: memory layout, process control block and process states

  • 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.

1.1.2 Creating processes with fork(), exec() and wait(); context switches and schedulers

  • fork: child is a copy; returns 0 in child, child PID in parent; memory is copied, not shared.
  • n sequential forks → 2ⁿ processes, 2ⁿ − 1 children; prints after forks happen once per process; inside a loop, add per iteration.
  • exec replaces the program; wait waits for a child; zombie = exited, not waited for; orphan = parent gone.
  • Context switch = save + load PCB (overhead).
  • Long-term (admission, degree of multiprogramming), short-term (CPU), medium-term (swapping).

CInterleaved GATE-style questions

Q1 · MCQ · 1 mark(s) — States

A process requests a disk read. It moves from Running to:

  1. (A) Terminated
  2. (B) Waiting
  3. (C) New
  4. (D) Ready

Q2 · MCQ · 1 mark(s) — Layout

A global variable int count = 0; is stored in the:

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

Q3 · NAT · 1 mark(s) — Fork

fork(); fork(); fork(); printf("hi"); How many times is hi printed?

Numerical answer: ________

Q4 · NAT · 2 mark(s) — Fork

if (fork() == 0) fork(); printf("y"); How many times is y printed?

Numerical answer: ________

Q5 · NAT · 2 mark(s) — Fork

for (i = 0; i < 2; i++) { if (fork() == 0) printf("c"); } How many c's are printed?

Numerical answer: ________

Q6 · MCQ · 1 mark(s) — Return value

In the parent process, fork() returns:

  1. (A) the parent's own PID
  2. (B) 0
  3. (C) the child's PID
  4. (D) −1 always

Q7 · MCQ · 1 mark(s) — Zombie

A child has exited but its parent has not called wait(). The child is a(n):

  1. (A) zombie
  2. (B) thread
  3. (C) daemon
  4. (D) orphan

Q8 · MSQ · 2 mark(s) — After fork

Immediately after a successful fork(), which are true?

  1. (A) The child's fork() returned 0.
  2. (B) A change to a global variable in the child is seen by the parent.
  3. (C) Parent and child run the same code.
  4. (D) Both continue from the statement after fork().

DAnswer Vault

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

🔐 Open the Answer Vault

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

It must wait for the I/O.

  • (A) is wrong: It has not finished.
  • (C) is wrong: Not a backward transition.
  • (D) is wrong: Ready means only the CPU is missing.

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

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

Globals and statics.

  • (A) is wrong: Dynamic memory.
  • (B) is wrong: Kernel bookkeeping.
  • (C) is wrong: Locals.

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

Q3 Answer: 8 · 1 mark(s)

2³.

Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers

Q4 Answer: 3 · 2 mark(s)

Parent prints once; the child forks, so two more.

Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers

Q5 Answer: 3 · 2 mark(s)

One new child in iteration 0, two new children in iteration 1; each child prints once.

Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers

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

The child gets 0.

  • (A) is wrong: The parent already knows its PID.
  • (B) is wrong: That is the child's value.
  • (D) is wrong: Only on failure.

Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers

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

Its entry stays until reaped.

  • (B) is wrong: Not related.
  • (C) is wrong: A background service.
  • (D) is wrong: Orphans have lost their parent.

Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers

Q8 Answer: (A) (C) (D) · 2 mark(s)

Memory is copied.

  • (B) is wrong: Separate copies.

Re-read: Lesson 1.1.2 — Creating processes with fork(), exec() and wait(); context switches and schedulers

Ready for the next idea?

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