Every program you run, from a browser to a compiler, depends on a layer of software it never sees directly. That layer is the operating system. This unit explains what an operating system does, the main kinds of operating systems, how programs ask it for help through system calls, and how its parts are arranged.
1. What is an operating system?
A computer's hardware (the processor, memory, disks and devices) can do nothing useful on its own. An operating system (OS) is the program that controls this hardware and offers a simpler, safer way for other programs and for people to use it.
DefinitionAn operating system is a program that manages the computer's hardware, provides a base for application programs, and acts as an intermediary between the user and the hardware.
It helps to look at the OS from two sides:
As a resource manager – it shares the processor, memory, storage and devices fairly and efficiently among many programs and users.
As an extended machine – it hides the messy details of the hardware behind clean services, so a program can say "write this file" instead of steering a disk head.
Figure 1. The operating system sits between programs and the hardware
2. Functions of an operating system
Function
What the OS does
Process management
Creates and ends processes, schedules them on the CPU, and lets them communicate and synchronise.
Memory management
Keeps track of which parts of memory are in use, gives memory to processes and takes it back.
File management
Creates, deletes and organises files and directories, and maps them onto storage.
Device (I/O) management
Controls devices through drivers, buffers data and handles interrupts.
Protection and security
Controls who may use which resource and defends the system against misuse.
User interface
Offers a command line, a graphical interface or a touch interface.
3. Types of operating systems
Type
Idea
Example use
Batch
Similar jobs are collected and run one after another with no user interaction.
Early mainframes, payroll runs
Multiprogramming
Several programs are kept in memory; when one waits for I/O, the CPU switches to another, so the CPU is rarely idle.
Mainframe job processing
Time-sharing (multitasking)
The CPU switches between tasks so quickly, in small time slices, that each user feels the machine is theirs.
Linux, Windows, macOS desktops
Multiprocessor
Two or more processors share memory and work in parallel.
Servers, multi-core PCs
Distributed
Separate computers joined by a network work together and appear as one system.
Cluster and cloud systems
Real-time
Results must arrive within a fixed deadline. In a hard real-time system a missed deadline is a failure; in a soft one it only lowers quality.
Airbag control (hard), video streaming (soft)
Mobile and embedded
Built for limited power, memory and screen size.
Android, iOS, washing machine controllers
Exam tipMultiprogramming keeps the CPU busy by switching when a job waits. Multitasking (time-sharing) switches on a timer so users get quick responses. Multiprocessing means more than one CPU. Questions often ask you to tell these three apart.
4. User mode, kernel mode and system calls
If any program could touch the hardware directly, one faulty program could crash the whole machine. To prevent this the processor has two modes, marked by a mode bit:
User mode – ordinary programs run here and cannot execute privileged instructions.
Kernel mode – the core of the OS (the kernel) runs here with full access to the hardware.
DefinitionA system call is the way a program asks the operating system for a service. The call switches the processor from user mode to kernel mode, the kernel does the work, and control returns to the program in user mode.
Common groups of system calls, with UNIX examples:
Group
Examples
Process control
fork(), exec(), exit(), wait()
File management
open(), read(), write(), close()
Device management
ioctl(), read(), write()
Information maintenance
getpid(), alarm(), sleep()
Communication
pipe(), shmget(), mmap()
Protection
chmod(), umask(), chown()
Programs rarely make system calls by hand. A library function such as printf() in C does the formatting in user mode and then calls write(), which enters the kernel.
5. Structure of an operating system
Operating systems are large programs, and the way their parts are arranged affects speed, reliability and how easy they are to change.
Monolithic – the whole OS runs as one large program in kernel mode. Fast, because parts call each other directly, but a bug anywhere can bring down the system. Traditional UNIX and Linux follow this design; Linux adds loadable modules.
Layered – the OS is split into layers, each using only the layer below it. Easy to test and debug, but passing through many layers is slow.
Microkernel – only the essentials (scheduling, basic memory handling, message passing) stay in the kernel; file systems and drivers run as user-mode servers. More reliable and secure, but messages between parts cost time. Examples: MINIX 3, QNX.
Hybrid – mixes the two approaches for speed and flexibility. Windows NT and the macOS kernel (XNU) are hybrids.
Point
Monolithic kernel
Microkernel
Kernel size
Large
Small
Speed
Faster: direct calls inside the kernel
Slower: parts talk by messages
Reliability
A faulty driver can crash the system
A faulty server can be restarted alone
Adding features
Usually means rebuilding or loading a module
Add a new user-mode server
6. How a computer boots
Power on: the firmware (BIOS or UEFI) runs from read-only memory.
The firmware runs a power-on self test (POST) to check the hardware.
It finds a boot device and loads the bootloader (for example GRUB on Linux).
The bootloader loads the kernel into memory and starts it.
The kernel sets up memory and devices and starts the first user process (init or systemd on Linux), which starts everything else.
7. Quick revision
An OS manages hardware and provides services to programs and users.
Main functions: process, memory, file, device, protection and user interface.