OS resource management and processes
| English | Chinese | Pinyin |
|---|---|---|
| process | 进程 | jìn chéng |
| multi-tasking | 多任务 | duō rèn wù |
| spooling | 假脱机 | jiǎ tuō jī |
| caching | 缓存 | huǎn cún |
| scheduler | 调度器 | diào dù qì |
| round robin | 轮转 | lún zhuàn |
| context switch | 上下文切换 | shàng xià wén qiè huàn |
| process control block | 进程控制块 | jìn chéng kòng zhì kuài |
Sharing the computer's resources
- Many programs compete for the CPU, memory, disk and I/O.
- The OS shares them fairly and efficiently so the system stays responsive.
- It manages each program as a process 进程.
Maximising resource use
- Multi-tasking 多任务 — switch the CPU quickly between processes so several seem to run at once.
- Memory management — give each process memory; page to disk when RAM runs out (too many page faults cause disk thrashing).
- Spooling 假脱机 — print jobs queue on disk, so the CPU never waits for the slow printer.
- Caching 缓存 — keep recently-used data in fast cache/RAM.
- The OS also hides the hardware behind a user interface (CLI or GUI).

The processor is a key resource the OS must share between tasks.
Multi-tasking lets several programs appear to run at once by:
The OS rapidly switches the single CPU between processes so they all seem to progress together.
Spooling helps the system because:
Spooling buffers print jobs to disk so the fast CPU is not held up by the slow printer.
Process scheduling
- A process is a program in execution (its code, state, memory, open files).
- The scheduler 调度器 picks which ready process runs next, and for how long.
- Round robin 轮转 gives each process a fixed time slice, then sends it to the back of the queue (responsive and fair).
- Other process management policies: first-come-first-served, shortest job first, and shortest remaining time.

Round-robin scheduling gives each process a fixed time slice in turn, then moves it to the back of the queue

The OS also manages memory (RAM), deciding what to keep in it.
Round-robin scheduling gives each ready process a fixed time slice, then moves it to the back of the queue — making it fair and responsive.
Equal time slices in turn stop any one process hogging the CPU, so interactive programs stay responsive.
Process states and context switching 上下文切换
- A process is new, ready (waiting for the CPU), running, blocked (waiting for I/O), or terminated.
- Running → ready when its slice ends; running → blocked when it requests I/O; blocked → ready when the I/O finishes.
- Switching process means saving one's state to its process control block 进程控制块 (PCB) and restoring another's — a context switch (a small cost each time).

A process moves between new, ready, running, blocked and terminated as the scheduler and I/O dictate
- The kernel (the OS core) acts as an interrupt handler; interrupt handling drives this low-level scheduling.
The life of a process
Tap round the loop a process travels. It only runs when the scheduler picks it; needing I/O sends it to blocked, and finishing its time slice sends it back to ready — round and round until it's done.
Match each process state to what it means.
A process cycles ready → running → (blocked) → ready, until it terminates.
A context switch involves:
The OS saves the running process's registers/PC to its PCB and loads the next process's — a small overhead each switch.
You've got it
- the OS maximises resources via multi-tasking, paging, spooling and caching
- a process is a running program; the scheduler chooses the next ready one (round robin = time slices)
- states: new → ready → running, with blocked for I/O, then terminated
- a context switch saves/restores state via the PCB