Phase 0Ch 0.1 What an operating system does
ACompressed recap
CPU, RAM (volatile), disk (permanent), I/O; program vs process; bits and bytes; KB = 2¹⁰; n address bits ↔ 2ⁿ bytes. OS = resource manager + protection; user vs kernel mode; privileged instructions (I/O, timer, interrupts, memory registers); interrupts vs traps; timer interrupt. System call = trap into kernel and back (2 mode switches); library functions vs system calls.
BMerged rule card
0.1.1 Inside a computer: CPU, memory, disk, I/O; bits, bytes and powers of two
- CPU executes, RAM holds current work (volatile), disk stores permanently, I/O connects the outside.
- Program = file; process = program in execution.
- Byte = 8 bits; n bits → 2ⁿ values; 1 KB = 2¹⁰, 1 MB = 2²⁰, 1 GB = 2³⁰.
- 2ⁿ bytes ↔ n address bits; divide powers of two by subtracting exponents.
0.1.2 What an operating system does: kernel, user mode and kernel mode, interrupts
- OS = resource manager + abstraction + protection; kernel runs in kernel mode.
- Mode bit: user mode (restricted) vs kernel mode (all instructions).
- Privileged: I/O, set timer, enable/disable interrupts, memory-management registers, halt. Not privileged: arithmetic, read clock, trap/system-call instruction.
- Interrupt = from hardware; trap/exception = from the running program; timer interrupt returns control to the OS.
- Multiprogramming keeps the CPU busy; time-sharing switches fast for interaction.
0.1.3 System calls: how programs ask the operating system for help
- System call: wrapper → parameters + number → trap → kernel handler via system-call table → result → return to user mode (2 mode switches).
- Parameters: registers, memory block, or stack.
- Categories: process (fork, exec, exit, wait), file (open, read, write, close, lseek), device, information, communication.
- printf, malloc, strlen are library functions; write, brk are system calls.
- Monolithic kernel vs microkernel.
CInterleaved GATE-style questions
Q1 · NAT · 1 mark(s) — Address bits
How many address bits does a 2 GB byte-addressable memory need?
Numerical answer: ________
Q2 · NAT · 2 mark(s) — Division
A 1 GB memory is divided into 8 KB blocks. How many blocks?
Numerical answer: ________
Q3 · MCQ · 1 mark(s) — Process
Two copies of the same text editor are open. How many processes are running the editor?
- (A) 2
- (B) 0
- (C) It depends on the file size
- (D) 1
Q4 · MCQ · 1 mark(s) — Privilege
Which instruction need NOT be privileged?
- (A) Halt the processor
- (B) Load the base/limit memory registers
- (C) Read the processor clock
- (D) Disable interrupts
Q5 · MCQ · 1 mark(s) — Traps
Division by zero in a user program causes:
- (A) a hardware interrupt from a device
- (B) a trap (exception) to the OS
- (C) a switch to user mode
- (D) nothing; the result is 0
Q6 · MSQ · 2 mark(s) — Modes
Which statements are true?
- (A) The mode bit records whether the CPU is in user or kernel mode.
- (B) A timer interrupt lets the OS regain the CPU.
- (C) User programs may execute I/O instructions directly.
- (D) The kernel runs in kernel mode.
Q7 · NAT · 1 mark(s) — System calls
A program calls printf 10 times; the library buffers the text and issues 2 write system calls. How many times does the program enter the kernel for printing?
Numerical answer: ________
Q8 · MCQ · 1 mark(s) — Library vs system call
malloc is best described as:
- (A) an interrupt handler
- (B) a library function that may use a system call (brk or mmap) to get more memory
- (C) a privileged instruction
- (D) a system call
DAnswer Vault
Try the questions first. Open when you are ready to check.
🔐 Open the Answer Vault
Q1 Answer: 31 · 1 mark(s)
2 × 2³⁰ = 2³¹.
Re-read: Lesson 0.1.1 — Inside a computer: CPU, memory, disk, I/O; bits, bytes and powers of two
Q2 Answer: 131072 · 2 mark(s)
2³⁰/2¹³ = 2¹⁷.
Re-read: Lesson 0.1.1 — Inside a computer: CPU, memory, disk, I/O; bits, bytes and powers of two
Q3 Answer: (A) · 1 mark(s)
Each running copy is a process.
- (B) is wrong: They are running.
- (C) is wrong: Unrelated.
- (D) is wrong: One program, two processes.
Re-read: Lesson 0.1.1 — Inside a computer: CPU, memory, disk, I/O; bits, bytes and powers of two
Q4 Answer: (C) · 1 mark(s)
Reading the clock cannot harm anyone.
- (A) is wrong: Would stop everything.
- (B) is wrong: Would break memory protection.
- (D) is wrong: Could stop the OS from regaining control.
Re-read: Lesson 0.1.2 — What an operating system does: kernel, user mode and kernel mode, interrupts
Q5 Answer: (B) · 1 mark(s)
An error in the running program.
- (A) is wrong: No device is involved.
- (C) is wrong: It enters kernel mode.
- (D) is wrong: The OS must handle it.
Re-read: Lesson 0.1.2 — What an operating system does: kernel, user mode and kernel mode, interrupts
Q6 Answer: (A) (B) (D) · 2 mark(s)
I/O instructions are privileged.
- (C) is wrong: They must go through system calls.
Re-read: Lesson 0.1.2 — What an operating system does: kernel, user mode and kernel mode, interrupts
Q7 Answer: 2 · 1 mark(s)
Only the write calls trap.
Re-read: Lesson 0.1.3 — System calls: how programs ask the operating system for help
Q8 Answer: (B) · 1 mark(s)
Runs in user mode, occasionally asks the kernel.
- (A) is wrong: Not a handler.
- (C) is wrong: Not an instruction.
- (D) is wrong: The system calls are brk/mmap.
Re-read: Lesson 0.1.3 — System calls: how programs ask the operating system for help