Software and the operating system
Without software, a computer is a box of parts. System software looks after it; application software lets the user do a job. The OS manages the hardware and runs the applications.
System software
Manages and maintains the computer’s hardware and software: the services the computer needs.
e.g. the operating system; utility software such as anti-virus or a defragmenter.
Application software
Lets the user perform a task: the services the user needs.
e.g. word processor, spreadsheet, database, web browser, game, photo editor.
The nine functions of an operating system (OS)
Almost everything you do on a computer passes through the OS. Name each function in full and say what it does.
Managing files
create, open, save, copy, rename and delete files and folders
Handling interrupts
receive interrupt signals, give them a priority, manage the queue and call the right service routine (ISR)
Providing an interface
lets the user communicate with the computer, e.g. a GUI or command line
Managing peripherals and drivers
installs and manages device drivers; sends data to and receives data from devices
Managing memory
gives each program the memory it needs, frees it afterwards, stops programs using the same location
Managing multitasking
lets several programs run at once by sharing processor time between them
Providing a platform for running applications
lets application software run and use the hardware
Providing system security
controls access, e.g. passwords and permissions; works with anti-malware
Managing user accounts
creates accounts with a username and password, each with its own files and settings
Running an application needs hardware, firmware and an OS
The OS is a program too, so something has to load it when the power comes on. Read the chain from power-on: each layer starts, loads or runs the next.
- 1Firmware is permanent instructions stored in ROM that control the hardware and give the operating system a platform to run on.
- 2At power-on, the bootloader (firmware) runs on the hardware and loads the operating system.
- 3Applications then run on the operating system.
Firmware is permanent instructions stored in ROM that control the hardware and give the operating system a platform to run on. At power-on, the bootloader (firmware) runs on the hardware and loads the operating system. Applications then run on the operating system.
1 Is a spreadsheet system software or application software? What about anti-virus software?
2 Which operating system function stops two programs using the same memory location?
3 Put these in order: operating system runs, bootloader runs, power on, application runs.
- 1spreadsheet: application software (a task for the user) · anti-virus: system software (a utility that looks after the computer)
- 2managing memory
- 3power on → bootloader → operating system → application
Handling interrupts
A processor works through one instruction after another, but the world does not wait: a key is pressed, or the printer runs out of paper. An interrupt is a signal from hardware or software telling the processor that something needs attention.
An interrupt comes either from a device or from a program that goes wrong. Give an example of each type, and say which type an event is.
Hardware interrupts
pressing a key · moving or clicking the mouse · printer out of paper or ink · a robot hitting an obstacle or its battery running low
Software interrupts
division by zero · two processes trying to access the same memory location · a software error, e.g. a program crashing
Hardware interrupts
- pressing a key
- moving or clicking the mouse
- printer out of paper or ink
- a robot hitting an obstacle or its battery running low
Software interrupts
- division by zero
- two processes trying to access the same memory location
- a software error, e.g. a program crashing
How an interrupt is handled
The processor can stop what it is doing, but it must be able to pick it up again exactly where it left off. Follow the printer’s interrupt from the top, and watch the values in the registers go onto the stack and come back.
What happens as a result?
- 1The ISR deals with the event: for example, the character for a key press is shown, or an alert is displayed.
- 2Any waiting interrupt with higher priority than the original process is serviced first.
- 3When none remains, the processor restores the saved state and resumes the original process.
The ISR deals with the event: for example, the character for a key press is shown, or an alert is displayed. Any waiting interrupt with higher priority than the original process is serviced first. When none remains, the processor restores the saved state and resumes the original process.
1 A phone is playing music when its battery runs low and sends an interrupt. Is this a hardware or software interrupt?
2 What is saved before the ISR runs, and where is it saved?
3 The new interrupt has a lower priority than the current process. What happens?
- 1hardware (the battery is a device)
- 2the register values (the current state) are copied onto the stack
- 3the process carries on with its next FDE cycle; the interrupt waits in the queue
Programming languages and translators
A processor only understands binary instructions, but people think in words. Programming languages sit somewhere between the two. A high-level language is easy for people to read but must be translated. A low-level language is close to the processor. A compiler or an interpreter does the translating.
High-level language
Uses English-like statements that are easy for people to understand. It must be translated into machine code before the processor can run it.
Low-level language
Close to machine code, the binary instructions the processor executes. Machine code and assembly language are both low-level.
High-level or low-level
Give an advantage and a disadvantage of each.
| Advantages | Disadvantages | |
|---|---|---|
| High-level English-like, e.g. Python |
easy to read, write and debug · machine independent (portable) · one statement can do many operations |
must be translated before it runs · cannot directly manipulate hardware · may run slower and use more memory |
| Low-level machine code; assembly |
directly manipulates hardware · can run faster and use memory/storage more efficiently |
hard to read, write and debug · machine specific: only works on one type of processor |
LDA, ADD, STO) to communicate directly with the hardware. It needs an assembler (software) to translate it into machine code.Translating high-level code: compiler or interpreter
Both translators get the same three-statement program, with a mistake in statement 2 (outlined in orange). Follow each row to see what happens at the error, then use the table to compare them and choose one for a job.
| Compiler | Interpreter | |
|---|---|---|
| Translates | the whole program at once, before it runs | one statement at a time, executing each straight away |
| Errors | an error report for the whole code: errors can be fixed together | stops at the first error; correct it before continuing |
| Output | an executable file: repeat tests without translating each time; the final program runs faster | no executable: translated every time it runs, which is slower |
| A suitable use | distributing the final program: users need no translator or source code | testing unfinished sections: the rest of the program need not work yet |
1 Which translator gives an error report for the whole program at once?
2 A programmer wants to test half-finished code. Which translator suits this, and why?
3 Give one advantage of a low-level language over a high-level one.
- 1the compiler
- 2an interpreter: it runs one statement at a time, so the part already written can be tested and the rest need not work yet
- 3it can directly manipulate hardware, and may run faster and use memory more efficiently
Integrated development environments
Writing a program means typing, translating, running and fixing it, again and again. An integrated development environment (IDE) brings the tools to write, translate, run and debug a program into one application.
A short program open in an IDE, with one word mistyped (prnt). Each numbered mark points at one of its tools.
Seven functions
The numbers match the marks on the IDE above. Say what each function does for the programmer.
| Function | How it helps the programmer | |
|---|---|---|
| 1 | Code editor | a place to type and edit the source code, with line numbers |
| 2 | Prettyprint | colour-codes key words (syntax highlighting) and indents code, so it is easier to read |
| 3 | Auto-completion | suggests the rest of a key word or name as it is typed, saving time and typing errors |
| 4 | Auto-correction | corrects a mistyped word or name, e.g. prnt → print |
| 5 | Translator | a compiler and/or interpreter built in, to translate the code into machine code |
| 6 | Run-time environment | runs the program inside the IDE so it can be tested, showing input and output |
| 7 | Error diagnostics | identifies errors and highlights the line; debugging tools such as breakpoints, stepping through code and watching variables |
Why use an IDE?
- All the tools are in one place, so code is written, run and tested without switching programs.
- Errors are found and located quickly, so debugging is faster.
- Code is laid out consistently, so it is easier to read and maintain.
Translators inside the IDE
An IDE may provide an interpreter (to test sections while developing) and a compiler (to create the final executable to distribute).
1 Which IDE feature changes prnt to print?
2 Which feature colours key words and indents the code?
3 Give one reason a programmer might use an IDE.
- 1auto-correction
- 2prettyprint
- 3all the tools are in one place, so code can be written, run and tested without switching programs