Definition
Operating System
An Operating System (OS) is a system software that acts as an intermediary between the user of a computer and the computer hardware. It allows for the execution of a program by abstracting the underlying machine architecture.
The OS has two primary functions:
- Extended Machine: It provides abstractions (processes, files, address spaces) that hide the complexity of the hardware.
- Resource Manager: It controls the allocation of processors, memories, and I/O devices among competing programs.
Illusion
The OS Illusion
The OS creates the illusion that a program has exclusive access to the hardware (infinite memory, dedicated processor) by multiplexing resources in time (scheduling) and space (virtual memory).
Control Structures
To manage the complexity of a multitasking system, the kernel maintains several sets of control structures (tables). These provide the necessary information about the current state of all hardware and software resources.
The OS typically organises its information into four distinct types of tables:
- Memory Tables: Track main and secondary memory allocation, block protection, and virtual memory mapping.
- I/O Tables: Manage I/O devices, channels, and pending transfers.
- File Tables: Store information about file locations on storage, current status, and metadata.
- Process Tables: The central structures for managing active processes. Each entry points to a PCB.
History and Evolution
The development of modern operating systems has been driven by the shifting costs of hardware versus human labour. Early systems focused on maximising hardware utilisation, while modern ones prioritise user comfort and productivity.
1. Serial Processing (1950s)
No operating system existed. Users had exclusive access to the machine one at a time.
- Input: Console switches, punch cards.
- Problem: Highly error-prone and significant setup time (loading tapes, setting switches).
- Solution: Introduction of subroutine libraries for common tasks (e.g., IO) and “setup specialists.”
2. Simple Batch Systems (1960s)
A permanent software component called a Monitor managed the execution of “jobs.”
- Mechanism: Users submitted jobs on punched cards. The monitor read the JCL (Job Control Language) commands to automatically load and run programs.
- Hardware Support: Required Memory Protection (to protect the monitor), Timers (to prevent job monopolies), Interrupts, and Privileged Instructions.
3. Multiprogramming (1965)
Designed to bridge the speed gap between the CPU and IO devices.
- Problem: A single program is either CPU-bound or IO-bound, leaving parts of the system idle.
- Solution: The OS keeps multiple processes in memory. When one process waits for IO, the CPU switches to another.
4. Time-Sharing Systems (1970s)
Designed to support multiple interactive users simultaneously.
- Mechanism: Uses Preemptive Scheduling and priorities to give each user the illusion of a dedicated machine.
- Innovation: Led to the development of complex file systems for persistent data availability.
System Interfaces
The OS acts as a bridge between the user and the hardware via three primary interfaces:
- Instruction Set Architecture (ISA): The boundary between hardware and software. It defines the machine code instructions, registers, and memory addressing.
- Application Binary Interface (ABI): Defines the standard for binary portability across different OS instances on the same architecture (e.g., system call conventions).
- Application Programming Interface (API): High-level language interface (e.g., POSIX, Win32) that allows developers to access OS services through library calls.
OS Roles
1. Extended Machine (Service Provider)
The OS provides a level of abstraction that hides the hardware complexity. Services include:
- Program execution: Loading and running applications.
- IO operations: Unified interface for diverse peripherals.
- File system access: Persistent storage management.
- Communication: IPC and networking.
- Error detection: Handling hardware/software failures.
2. Resource Manager
The OS manages the competition for limited hardware resources among active processes.
- Processor: Time allocation (scheduling).
- Memory: Space allocation (paging/segmentation).
- IO Devices: Access control and queuing.
- Data: Management of shared files and buffers.