You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson examines the operating system as a resource manager, surveying its core functions — process and processor management, memory management, I/O and peripheral management, file management and interrupt handling — and the major types of operating system. Memory management and scheduling each have their own dedicated lesson; here you get the joined-up overview and pointers to that depth.
This lesson develops OCR H446 section 1.2.1 (Operating Systems). It treats the OS as the manager of the machine's resources and requires you to describe each core function and to distinguish the main types of OS (multi-tasking, multi-user, distributed, embedded and real-time). Two functions are deliberately given only an overview here because they are taught in full elsewhere: memory management (paging, segmentation, virtual memory, thrashing) in the Memory Management lesson, and processor scheduling (round robin, FCFS, SJF, SRT, multilevel feedback queues) in the Scheduling Algorithms lesson. Use those lessons for the worked detail and this one for how the functions fit together.
A computer has a small number of scarce resources — CPU time, RAM, disk space, and a handful of peripherals — and many programs (and possibly many users) that all want them at once. The fundamental job of the OS is to manage those resources: decide who gets what, when, and for how long, while stopping any program from interfering with another. Everything in this lesson is an instance of that single idea.
flowchart TB
subgraph OS["Operating System (resource manager)"]
PM["Processor / process<br/>management"]
MM["Memory<br/>management"]
IO["I/O & peripheral<br/>management"]
FM["File<br/>management"]
IH["Interrupt<br/>handling"]
end
APP["Application processes"] --> OS
OS --> CPU["CPU time"]
OS --> RAM["RAM"]
OS --> DEV["Peripherals"]
OS --> DISK["Secondary storage"]
A process is a program that is currently being executed, along with its associated data, registers and state information. The OS must manage many processes that may be competing for CPU time. Processor scheduling — deciding which ready process runs next — is the part of process management covered in the Scheduling Algorithms lesson; here we cover the surrounding machinery: process states, the process control block, and context switching.
| State | Description |
|---|---|
| New | The process has been created but not yet admitted to the ready queue |
| Ready | The process is in memory and waiting for CPU time. It has everything it needs except the CPU |
| Running | The process is currently being executed by the CPU |
| Waiting (Blocked) | The process is waiting for an event (e.g. I/O completion, user input) |
| Terminated | The process has finished execution |
stateDiagram-v2
[*] --> New
New --> Ready : admit
Ready --> Running : scheduler dispatches
Running --> Ready : time slice expired / preempted
Running --> Waiting : I/O request
Waiting --> Ready : I/O complete
Running --> Terminated : process completes
Terminated --> [*]
Two transitions are worth dwelling on. Running → Ready happens when a pre-emptive scheduler interrupts a process whose time slice has expired (this is the link to the Scheduling Algorithms lesson). Running → Waiting happens when a process requests slow I/O: rather than wasting the CPU spinning while a disk read completes, the OS blocks the process and gives the CPU to someone else, then unblocks it (Waiting → Ready) when the I/O finishes — which is signalled by an interrupt.
Every process has a Process Control Block — a data structure maintained by the OS that stores all the information needed to manage the process.
| PCB Field | Content |
|---|---|
| Process ID (PID) | Unique identifier for the process |
| Process state | Current state (ready, running, waiting, etc.) |
| Program counter | Address of the next instruction to execute |
| CPU registers | Saved register values when the process is not running |
| Memory allocation | Information about the memory pages/segments assigned |
| Priority | The process's scheduling priority |
| I/O status | List of I/O devices allocated to the process |
| Accounting info | CPU time used, start time, etc. |
The PCB is what makes multi-tasking possible: because the full state of a paused process is saved, the OS can resume it later exactly where it left off, as if it had never been interrupted.
When the OS switches the CPU from one process to another, it performs a context switch:
Context switching is overhead — during the switch the CPU does no useful application work. This cost is exactly why the choice of time quantum matters in round-robin scheduling (covered in Scheduling Algorithms): too many switches and the machine spends its time bookkeeping rather than computing. A context switch is itself usually triggered by an interrupt (a timer interrupt for pre-emption, or an I/O-completion interrupt), tying process management to the interrupt-handling section below.
Worked trace of a context switch. Suppose process A is running when its time slice expires:
| Step | What the OS does | Effect |
|---|---|---|
| 1 | Timer interrupt fires | CPU stops executing A at the next instruction boundary |
| 2 | Save A's PC, registers and status flags into A's PCB | A's exact state is preserved |
| 3 | Mark A as Ready and place it on the ready queue | A is no longer running but not finished |
| 4 | Scheduler selects process B; dispatcher loads B's saved state from B's PCB | B's registers and PC are restored |
| 5 | Mark B as Running; resume from B's restored PC | B continues exactly where it last left off |
Because the entire state lives in the PCB, B cannot tell it was ever paused — and later, when A is dispatched again, the same restore brings A back to the instruction after the one it was interrupted on. This is the mechanism that turns one CPU into the illusion of many.
The OS must allocate and manage main memory (RAM) among all running processes, while protecting each process's memory from the others and letting the total demand exceed physical RAM.
| Goal | Explanation |
|---|---|
| Allocation | Assign memory to processes as they need it |
| Protection | Prevent one process from accessing another process's memory |
| Efficient use | Minimise wasted (unused) memory |
| Virtual memory | Allow processes to use more memory than physically available |
The two main techniques are paging (dividing memory into fixed-size pages and frames, mapped by a page table) and segmentation (dividing memory into variable-size, logically-meaningful segments). Virtual memory uses secondary storage as an overflow for RAM, and overusing it causes thrashing.
This is deliberately a summary. The full treatment — address translation, the page table and TLB, paging-vs-segmentation trade-offs, page replacement and disk thrashing, with worked examples and an address-translation diagram — is in the dedicated Memory Management lesson. For the exam, be able to state the goals above and name paging, segmentation and virtual memory; reach for the dedicated lesson for the mechanism.
The OS manages how files are stored on secondary storage, organised into directories, and accessed by users and programs.
| Function | Description |
|---|---|
| Creating and deleting files | The OS allocates space on disk and creates directory entries |
| Reading and writing | The OS translates file operations into disk read/write commands |
| Directory management | Organises files into a hierarchical directory (folder) structure |
| Access control | Manages permissions (read, write, execute) for different users |
| File naming | Maintains the mapping between human-readable file names and physical disk locations |
| Disk space allocation | Decides which blocks on the disk to use for each file |
| Method | How It Works | Advantages | Disadvantages |
|---|---|---|---|
| Contiguous | Each file occupies a continuous block of disk space | Fast sequential access; simple | Difficult to grow files; external fragmentation |
| Linked | Each block contains a pointer to the next block | No external fragmentation; files can grow easily | Slow random access (must follow chain); pointers use space |
| Indexed | An index block stores pointers to all data blocks | Fast random access; no external fragmentation | Index block overhead; extra disk read for index |
Access control connects file management to the OS's security role: the OS checks the requesting user's permissions before any read or write, so file management and protection are two sides of the same mechanism. Contiguous allocation also explains why magnetic disks suffer fragmentation and therefore why the defragmentation utility (from the System Software lesson) exists.
The OS presents files to users as a tree of directories (folders), even though the underlying blocks are scattered across the disk. A directory is itself just a special file that lists the names and disk locations of its contents, which is what lets the OS translate a human-readable path into a physical block address.
flowchart TB
R["/ (root)"] --> H["home"]
R --> E["etc"]
H --> U1["alice"]
H --> U2["bob"]
U1 --> D1["coursework"]
U1 --> F1["notes.txt"]
D1 --> F2["essay.docx"]
When you open /home/alice/coursework/essay.docx, the OS walks this tree one directory at a time, looking up each name to find the next directory's location, until it reaches the file's entry and discovers which blocks hold its data. The hierarchy is the user-facing abstraction; allocation methods and disk blocks are the physical reality beneath it.
Modern file systems are often journaled: before making a change, the OS writes a record of its intention to a journal (a log). If power is lost mid-write, on restart the OS replays or rolls back the journal so the file system is not left in a half-updated, corrupt state. This is the file-management equivalent of keeping a transaction log, and it shows that file management is not only about where data goes but about keeping it consistent when things go wrong.
The OS manages communication between the CPU and peripheral devices (keyboard, mouse, display, printer, disk, etc.). Peripherals are slow and varied; the OS hides both their slowness and their differences from applications.
| Component | Role |
|---|---|
| Device drivers | Software modules that translate generic OS commands into device-specific instructions. Each device type needs its own driver |
| I/O scheduler | Determines the order in which I/O requests are processed (e.g. disk scheduling algorithms) |
| Buffering | Temporarily stores data in memory while it is being transferred between a device and a process. Compensates for speed differences |
| Spooling | Used for devices that cannot handle interleaved data from multiple sources (e.g. printers). Jobs are queued and processed one at a time |
A device driver is the piece of software that knows the precise control codes for one model of hardware. The OS exposes a generic interface ("write these bytes to that device") and the driver translates it into the exact signals the hardware expects. This is why installing a new printer needs its driver, and why the same application can print to wildly different printers without change — the driver, not the application, absorbs the difference.
A buffer is a region of memory used to temporarily hold data during transfer.
flowchart LR
P["Process<br/>(fast writer)"] --> B["Buffer<br/>(RAM)"] --> D["Device<br/>(slow reader)"]
The process writes to the buffer quickly; the device drains it at its own (slower) pace. Buffering lets the CPU and the device run at very different speeds without the CPU having to stall — the process can carry on as soon as the data is in the buffer, instead of waiting for the device. When the device has consumed the buffer it raises an interrupt to ask for more, again linking I/O to interrupt handling.
Spooling (Simultaneous Peripheral Operations On-Line) is primarily used for printing:
The difference between buffering and spooling is a frequent exam trap: a buffer is a small region of RAM smoothing one continuous transfer; a spool is a disk-based queue of complete jobs from possibly many sources, processed one after another for a device (like a printer) that cannot interleave them.
An interrupt is a signal sent to the processor that an event needs immediate attention. Interrupts are how the OS reacts to the world without wastefully checking ("polling") every device all the time. They can come from hardware (a key pressed, a disk read finished, a timer ticked) or software (a program error such as division by zero, or a deliberate system call).
When an interrupt occurs the CPU runs the interrupt service routine (ISR) for that interrupt:
flowchart TB
A["CPU executing a process"] --> B["Interrupt signal raised"]
B --> C["Finish current instruction"]
C --> D["Save registers + PC"]
D --> E["Look up ISR in vector table"]
E --> F["Run interrupt service routine"]
F --> G["Restore registers + PC"]
G --> A
Interrupts can have priorities: a higher-priority interrupt may itself interrupt an ISR that is already running, so the OS may queue or nest them. This mechanism is the same one referenced in processor management — a timer interrupt is what lets a pre-emptive scheduler reclaim the CPU, and an I/O-completion interrupt is what moves a blocked process back to ready. Interrupt handling is therefore the glue connecting the fetch–decode–execute cycle to the OS's scheduling and I/O work.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.