System Software
Why a computer needs an operating system, the jobs it manages, the utilities and libraries that come with it, and how programs are translated, written and debugged.
Why a computer needs an operating system
The operating system sits between you, your apps and the hardware, so programs do not drive the hardware themselves.
Without an operating system (OS), every program would have to drive the hardware itself.
The OS sits between the user, the applications and the hardware. It does four jobs:
- Provides a user interface, so the user can work with the computer.
- Hides the complexity of the hardware. A program simply asks to save a file, and the OS deals with the disk.
- Manages the resources: processor time, memory, storage, input and output. Then several programs can share them safely.
- Provides a platform that application software runs on.
Example:A game on your phone does not control the screen and the storage itself. It asks the OS.
Memory management
Memory management hands out blocks of memory to programs, takes them back, and keeps each program out of the others' memory.
Main memory holds the OS and every program that is running.
Memory management does three things:
- Gives blocks of memory to a process when it starts, and takes them back when the process ends.
- Keeps a record of which blocks are in use and which are free.
- Protects each process's memory. No program can read or overwrite the memory of another program, or of the OS.
Watch out:In this simple model, a process that needs more blocks than are free cannot start.
Remember:Using part of the disk as virtual memory is A Level.
File, security, hardware and process management
Besides memory, the OS manages files, security, hardware and processes.
The OS has four more management tasks:
| Task | What the OS does |
|---|---|
| File management | organises files in folders; records where each file is stored; lets users create, open, copy, move, rename and delete files |
| Security management | runs user accounts, passwords and access rights, so each user reaches only what they are allowed to |
| Hardware management | talks to each device through its driver; handles input, output and queues such as the print queue |
| Process management | shares the processor between the running processes (scheduling), so many programs seem to run at once |
Example:You print, play music and type at the same time. Scheduling makes them all seem to run at once.
Utility software
Utility software comes with the OS and keeps the computer working well.
Utility software is a set of programs supplied with the OS. They maintain the computer and keep it working well. The syllabus names six kinds:
| Utility | What it does, and why |
|---|---|
| Disk formatter | sets up a disk's file system so the disk can be used; old files can no longer be reached |
| Virus checker | scans files for known virus signatures and suspicious actions; quarantines or deletes what it finds; needs regular updates |
| Defragmentation | puts each file's blocks back in one run, so files are read faster |
| Disk contents analysis / disk repair | analysis shows which files and folders use the space; repair finds and fixes errors in the file system, and marks bad sectors so they are not used again |
| File compression | makes files smaller: less storage, and faster to send |
| Back-up software | copies files to another device or place on a schedule, so they can be restored if lost |
Exam:Name the utility, say what it does, and say why that is needed.
Defragmentation has a note of its own, next.
Defragmentation
Defragmentation puts each file's scattered pieces back together on a hard disk, so the disk reads it faster.
How a file becomes fragmented:
- A hard disk stores each file in blocks.
- Files are deleted and new ones saved, so the free space is left in gaps.
- A new or growing file is split into pieces, scattered over the disk. It is fragmented.
- The read/write head must jump between the pieces, and that is slow.
A defragmenter moves the blocks so that:
- each file is in one continuous run
- the free space is together
This reduces head movement, so files are read faster.
Watch out:An SSD does not need defragmentation. It has no moving head, so a scattered file is read just as fast.
Program libraries
A program library is ready-made, tested code that programmers call instead of writing it again.
A program library is a collection of pre-written, pre-tested routines (functions and procedures). They are usually already compiled. Programmers call them from their own programs, for example for maths, graphics, files or networking.
New software is usually built partly from library code.
| Benefits | Drawback |
|---|---|
| saves time: the code does not have to be written and tested again | dependence: a routine with a bug, or one that does not quite fit, is hard to change |
| fewer errors: the routines are already tested | |
| the programmer only needs to know what a routine does and how to call it, not how it works |
Example:In the Python below, pi and pow come from the maths library.
import math
radius = 3.0
# pi and pow come from the maths library
area = math.pi * math.pow(radius, 2)
print(area)Dynamic link libraries
A DLL is loaded when the program runs, so many programs share one copy instead of each carrying its own.
| Static linking | DLL (Dynamic Link Library) | |
|---|---|---|
| When it is linked | when the program is built | at run time |
| Where the library code is | copied into the executable file: every program carries its own copy | the executable only records that it needs the DLL; the OS loads the DLL when the program runs |
| Copies in memory | one per program | one copy, shared by several programs |
Benefits of a DLL:
- Executables are smaller.
- Less memory is used.
- A DLL can be updated without recompiling the programs that use it.
Watch out:If the DLL is missing, or a wrong version replaces it, every program that uses it fails.
Three translators
A processor runs only machine code, so every other program must be translated first.
A processor can only execute machine code. So every other kind of program must be translated.
| Translator | Translates | How |
|---|---|---|
| Assembler | assembly language into machine code | one machine instruction for each assembly instruction |
| Compiler | a whole high-level program into machine code (object code) | before it runs; it reports the errors for the whole program; it produces an executable file that runs without the compiler |
| Interpreter | a high-level program | translates and executes one statement at a time; stops at the first error it reaches; produces no executable file |
Remember:An interpreter makes no executable file, so the interpreter is needed every time the program runs.
Compiler or interpreter: which and when
Interpret while you develop, because errors show at once; compile the finished product, because it runs faster.
| Compiler | Interpreter | |
|---|---|---|
| Translates | the whole program, before the run | one line, then runs it, then the next |
| Errors | all, in one report | stops at the first |
| Executable | yes: runs without the compiler | no: the interpreter is needed every run |
| Speed | fast: the translating was done before the run | slower: lines are translated each run |
| A change | recompile first | run again at once |
| Users get | the executable only | the source code and an interpreter |
An interpreter shows an error as soon as it reaches the line. A fix can be tested at once, even before the program is finished. That makes it good for writing and debugging.
Example:Inside a loop, an interpreter translates the same lines every time round. 3 lines run 1 000 times is 3 000 translations. A compiler does 3.
A compiled program can be given out without its source code, so the code is hard to copy or change.
Java: compiled and interpreted
Java is compiled once into bytecode, and a virtual machine on each computer runs that bytecode.
Some languages use both kinds of translation. Java is one.
- Java source code is compiled into bytecode. Bytecode is an intermediate code. It is not the machine code of any real processor.
- A Java Virtual Machine (JVM) runs the bytecode on each computer. It interprets it, or compiles parts of it just before they run, into that computer's machine code.
So the same bytecode runs on any computer that has a JVM.
Remember:The compile step has already found the syntax errors and done much of the translating.
Hello.java the source code
| Java compiler:
| translates once
Hello.class bytecode, not any
| processor's machine
| code; copied unchanged
|
JVM on A -> machine code for
processor A
JVM on B -> machine code for
processor BThe IDE: help while you write
An IDE puts the editor, translator and debugger in one program, and helps while you type.
An IDE (integrated development environment) puts an editor, a translator and a debugger in one program.
| Helps with | Feature | What it does |
|---|---|---|
| coding | context-sensitive prompts | suggest the keywords, variable names and parameters that fit where you are typing |
| initial error detection | dynamic syntax checks | underline an error, such as a misspelt keyword, as you type, before the program ever runs |
| presentation | prettyprint | colours keywords, variables and strings differently, and indents the code |
| presentation | expand and collapse | a block such as a loop can be collapsed to one line and expanded again |
The IDE: debugging
When a program gives a wrong answer, the debugger lets you pause, step and watch values to find the logic error.
When a program runs but gives the wrong answer, the debugger helps to find the logic error.
| Tool | What it does | Why it helps |
|---|---|---|
| Single stepping | runs the program one line at a time | you can follow the path it takes |
| Breakpoint | pauses the program when it reaches a chosen line | you can jump straight to the part you suspect |
| Report window (also called a watch window) | shows the current values of chosen variables and expressions while the program is paused | you can see the moment a value goes wrong |
Example:The program below should add 1 to 4, which is 10. But it prints 15. Step through it and watch Count and Total. You will see the loop run one time too many.
DECLARE Total : INTEGER DECLARE Count : INTEGER Total ← 0 FOR Count ← 1 TO 5 Total ← Total + Count NEXT Count OUTPUT "Sum of 1 to 4 is ", Total
Match each job to the part of the operating system that does it.
PICK ONE, THEN PICK ITS GROUP
- empty
- empty
- empty
- empty
- empty
- Click the stages below in the order they happen.
KEY TERMS
CHECK YOURSELF
1.A programmer is still writing and testing a program. Why is an interpreter useful at this stage?
2.What is the main benefit of a DLL over including the code in every program?
3.Which is a task of the operating system?
4.What is Java bytecode?
5.Which IDE feature stops a program at a chosen line so that the variables can be inspected?
6.Why is a solid state drive (SSD) not defragmented?