Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

1.2.1 Systems Software

GitHub last commit

Operating Systems

An operating system manages hardware and software resources, as well as providing an interface between user and hardware.

Resource Management

The first of seven categories, the OS is responsible for resource management. They allocate resources (RAM, CPU, and Storage) to specific tasks and try to maximise performance and power-efficiency. For example, the scheduler in an OS is responsible for prioritising what runs next on a CPU, so if you, for example, open a game, it will prioritise allocating resources to that, rather than OneDrive syncing in the background (more on these later).

File Management

The OS is also responsible for file management - that is, working with the file system that the drive is formatted with in order to store, retrieve, and manipulate data. OSes will provide some sort of user interface, usually a GUI, to allow the user to interface with the file system and gives files properties e.g. file names, directory the file is stored in, dates modified, EXIF data, etc.

Interrupt Handling

Interrupts are events that require the immediate attention of the CPU, such as mouse movements. These must be processed quickly in order for the system to feel responsive and respond to time-sensitive actions e.g. cancelling file deletion (more on these later).

Security

Operating systems usually provide some sort of security suite such as a firewall (e.g. nftables), virus scanning (e.g. Windows Defender), and file encryption (e.g. BitLocker). Different accounts on the system can be given various permissions, such as file permissions, being allowed to install software globally, and editing the firewall settings, etc.

Providing a Platform for Software

Software from third-parties will need to access system resources, and this is the responsibility of the operating system. This is done via system calls (syscalls), where a program will ask the opearting system to give it access to resources to allow it to carry out a task e.g. write data to a file, or render triangles on a GPU.

Providing UIs

Users need User Interfaces (obviously) in order to interact with a computer. An operating system at the very least will provide a CLI (command-line interface), but usually a GUI (graphical user interface) too. On mobile OSes such as iOS the CLI is usually hidden and only used for debugging, as mobile OSes need to optimise for ease-of-use through touch-friendly GUIs.

Note

Not all OSes provide GUIs, such as server OSes where a GUI would just consume unnecessary resources and would never be ued.

Utility Software

Utility software allows for the maintenance of the hardware and software systems running a computer. OSes will usually include at least a very basic set of utility software such as disk formatting, file compression, and package management.

Interrupts

A device or a piece of software can generate an interrupt and send this to the processor to trigger an ISR (interrupt service routine). They are used for handling real-time events such as mouse movements, device communication such as incoming network connections, and multitasking. They are concise and have a specific purpose.

TypeWhat it does
Hardware InterruptsAsynchronous interrupts generated by external devices, and will cause an ISR to run that will, for example, process a keyboard input in a game.
Software InterruptsSynchronous interrupts triggered by software or the OS itself, often generated when errors occur e.g. a network error, but also when I/O operations are needed such as when opening a file.
Trap InterruptsA type of software interrupt triggered by a user program’s instruction, such as a system call or an exception like division by zero, which forces the CPU to switch to kernel (low-level OS) mode and execute a handler before returning to the user process.

Note

A kernel is often referred to as the ‘core’ of an OS, which handles the interface between hardware and software and contains software such as basic device drivers and the code to power on a system once the BIOS/UEFI has handed it control.

If the interrupt is of a lower/equal priority to the current process then the current process continues. Otherwise:

  1. The contents of the registers are copied to a stack (special area of memory).
  2. The interrupt flag is set.
  3. The program counter is changed to point to the ISR. If a higher-priority interrupt comes in during handling, the lower-priority interrupt is added to the stack and the higher-priority one is dealt with first. Interrupts can also be nested, where an ISR could trigger another interrupt, and the CPU deals with these.
  4. After the interrupt completes, the previous register values are restored back from the stack and the interrupt flag is reset.

Important

Interrupts are not always run - masked interrupts are hardware interrupts that can be ignored or disabled by the system using interrupt-masking techniques, selectively ignoring non-critical interrupts. They help in managing system resources and are used routinely during normal system operation.