Software
The programs that bring hardware to life: system and application software, the jobs of the operating system, interrupts, high and low level languages, assembly, compilers and interpreters, and the IDE. Topic 4 of the 0478 / 2210 syllabus in full.
Hardware on its own does nothing. Software is the set of programs that tell the hardware what to do. This chapter looks at the two broad kinds of software, the operating system that manages everything, how the CPU responds to urgent events through interrupts, and the languages and tools programmers use to create software in the first place.
System Software vs Application Software
All software falls into two categories, based on who it serves: the computer itself, or the user.
| System software | Application software | |
|---|---|---|
| Purpose | Provides the services the computer needs to operate and manages the hardware | Provides the services the user needs to complete tasks |
| Runs on | Directly manages the hardware | Runs on top of the operating system |
| Examples | Operating systems (Windows, Linux, macOS), utility programs, device drivers, antivirus, disk defragmenter | Word processor, web browser, spreadsheet, games, photo editor |
Functions of the Operating System
The operating system (OS) is system software that manages the computer's hardware and software resources and provides a platform on which applications can run. You should be able to name and describe its main functions.
| Function | What it does |
|---|---|
| Managing files | Organises files into directories, handles reading and writing, and manages file permissions |
| Handling interrupts | Receives and prioritises interrupt signals and runs the matching interrupt service routines |
| Providing an interface | Gives the user a way to interact, either a graphical interface (GUI) or a command-line interface (CLI) |
| Managing peripherals and drivers | Loads device drivers so hardware such as a printer or keyboard works with the OS |
| Managing memory | Allocates RAM to running programs and manages virtual memory |
| Managing multitasking | Allows several programs to run at once by rapidly switching CPU time between them |
| Platform for applications | Provides interfaces so applications can use the hardware without controlling it directly |
| Managing security | Handles authentication, access control and firewall settings |
| Managing user accounts | Creates and manages user profiles, permissions and login details |
Hardware, Firmware and the OS: the Software Layers
Software runs in layers, and each layer depends on the one below it. Understanding this stack explains how a program you click on eventually controls the hardware.
Application Software
The programs the user runs, such as a browser or game
Operating System
Manages hardware and provides a platform for applications
Firmware (Bootloader, BIOS or UEFI)
Permanent software in ROM that starts the hardware and loads the OS
Hardware
The physical components: CPU, memory, storage and devices
Firmware is software permanently stored in ROM on the hardware. The bootloader, which is a piece of firmware, initialises the hardware and loads the operating system when the computer is switched on.
Interrupts
An interrupt is a signal sent to the CPU telling it that an event needs immediate attention. The CPU pauses what it is doing, deals with the event, and then carries on exactly where it left off. Interrupts are how a computer responds instantly to things like a key press while still running other programs.
Press play to watch the CPU pause its current task, save its state to the stack, run the interrupt service routine, then restore its state and resume.
The steps in handling an interrupt
- A device or program generates an interrupt signal
- The CPU finishes its current instruction (not the whole task)
- The CPU saves its current state, the registers and program counter, onto the stack
- The CPU runs the appropriate interrupt service routine (ISR)
- When the ISR finishes, the CPU restores the saved state and resumes the original task exactly where it paused
Two kinds of interrupt
| Hardware interrupts | Software interrupts |
|---|---|
| Generated by a physical device | Generated by a running program |
| Pressing a key on the keyboard | An attempt to divide by zero |
| Moving the mouse | Two processes trying to access the same memory location |
| A printer finishing a print job | A program requesting an operating system service (a system call) |
High Level and Low Level Languages
Programming languages sit on a scale. High level languages are close to human language and easy to work with. Low level languages are close to the machine and harder for humans but give precise control.
| High level language | Low level language | |
|---|---|---|
| Readability | English-like syntax, easy to read and write | Uses mnemonics or binary, hard to read |
| Debugging | Easier, the code is logical and structured | Harder, you must trace binary or mnemonics |
| Machine independence | Portable, runs on different machines with the right translator | Machine specific, written for one type of CPU |
| Hardware control | Cannot directly control hardware | Direct access to hardware registers and memory |
| Speed | Slightly slower after translation | Very fast, runs directly or almost directly |
| Examples | Python, Java, C++, VB.NET | Assembly language, machine code |
Assembly Language
Assembly language is a low level language that uses mnemonics, short human-readable codes, to represent machine code instructions. It is much easier to follow than raw binary while still giving direct control over the hardware.
; A short assembly program LDA 5 ; Load the value from memory address 5 into the accumulator ADD 3 ; Add the value from address 3 to the accumulator STA 10 ; Store the result into memory address 10 HLT ; Halt, stop execution
Compilers and Interpreters
A high level language cannot be run directly by the CPU. It must first be translated into machine code. There are two ways to do this, and the difference is a frequent exam topic.
Play to compare. The compiler translates the whole program at once before running. The interpreter translates and runs one line at a time, stopping at the first error.
| Compiler | Interpreter | |
|---|---|---|
| How it translates | The entire source code at once | One line at a time, executing as it goes |
| Output | Produces a standalone executable file | No executable file is produced |
| Speed when running | Faster, it is already translated | Slower, it translates every time it runs |
| Errors | Reports all errors together after compiling | Stops at the first error it meets |
| Typically used for | The final released version of a program | Developing and testing a program |
Assemblers
An assembler is the translator for assembly language. It converts an assembly language program into machine code. Because each assembly instruction maps to exactly one machine code instruction, the assembler's job is a direct one-to-one translation.
Integrated Development Environments (IDEs)
An IDE is an application that gives programmers a complete set of tools for writing, testing and debugging code, all in one place. Instead of switching between separate programs, everything is combined.
| Feature | What it does |
|---|---|
| Code editor | A text editor with syntax highlighting and formatting for writing code |
| Run-time environment | Lets the program be run and tested inside the IDE |
| Translator | A built-in compiler or interpreter to translate and run the code |
| Error diagnostics | Highlights syntax errors as you type and shows error messages |
| Auto-completion | Suggests completions for variable names, functions and keywords |
| Auto-correction | Suggests or applies fixes for common mistakes automatically |
| Prettyprint | Automatically formats code with correct indentation and spacing |
Exam Practice
System software provides the services the computer needs to operate and manages the hardware, for example an operating system and a device driver. Application software provides the services the user needs to complete tasks and runs on top of the operating system, for example a word processor and a web browser.
Any four of: managing files, handling interrupts, providing a user interface, managing peripherals and drivers, managing memory, managing multitasking, providing system security, and managing user accounts.
A device or program generates an interrupt signal. The CPU finishes its current instruction, then saves its current state, the registers and program counter, onto the stack. It runs the appropriate interrupt service routine to deal with the event. Once the routine finishes, the CPU restores the saved state and resumes the original task from where it paused.
A hardware interrupt is a physical event such as pressing a key on the keyboard or a printer finishing a job. A software interrupt is generated by a program, such as an attempt to divide by zero or a request for an operating system service.
A compiler translates the entire source code at once and produces a standalone executable file, then reports all the errors it found together after compilation. An interpreter translates and executes the code one line at a time, producing no executable file, and stops as soon as it reaches the first error.
An IDE is an application that provides a complete set of tools for writing, testing and debugging code in one place. Two features, for example: a code editor with syntax highlighting for writing code, and error diagnostics that highlight syntax errors as the programmer types.
