Skip to content

0478 · Unit 4 · Paper 1: Computer systems

Software.

0478 · Unit 4 · Software
Revisionbyexamplicity

Software and the operating system

§4.1 · Types of software and interrupts

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.

Power-on hardwareprocessor starts executingfirmwarestartsBootloader in ROMconfigures hardware andloads the OSloadsOperating systemmanages resources; providesa platformrunsApplicationthe user performs a task
Power-on hardwareThe processor starts executing firmwarestartsBootloader in ROMConfigures hardware and loads the OSloadsOperating systemManages resources; provides a platformrunsApplicationThe user performs a task
  1. 1
    Firmware is permanent instructions stored in ROM that control the hardware and give the operating system a platform to run on.
  2. 2
    At power-on, the bootloader (firmware) runs on the hardware and loads the operating system.
  3. 3
    Applications 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.

Your turn

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.

  1. 1
    spreadsheet: application software (a task for the user) · anti-virus: system software (a utility that looks after the computer)
  2. 2
    managing memory
  3. 3
    power on → bootloader → operating system → application
Tick what you can do now
Exam focusName the function in full and say what it does: “managing memory: allocates memory to each program”. “Manages users” is too vague, and an example on its own (“it has buttons”) is not enough.
Practise with m26/12 Q8(a), (b), (d); s26/11 Q4(d)
1 / 4
0478 · Unit 4 · Software
Revisionbyexamplicity

Handling interrupts

§4.1 · Types of software and 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.

RegistersStackPCACCPCACC12037Interrupt signal sentby a device or by softwareprinter: out of paperPlaced in the interrupt queueordered by priorityinterrupt queueprinter · high priorityFinish the current FDE cyclethen check the interrupt queueHigher priority than thecurrent process?NoRun the next FDE cycleof the current processYesSave the current processregisters copied onto the stack12037Check source; call ISRthe matching routine runsand handles the event9002ISR = interrupt service routine (interrupt handler)Another higher-priorityinterrupt waiting?Yes: service it nextNoRestore from the stackstate reloaded; process resumes12037
RegistersStackPCPCACCACC12037printer: out of paperInterrupt signal sentBy a device or by softwarePlaced in the interrupt queueOrdered by priorityprinter · high priorityFinish the current FDE cycleThen check the interrupt queueHigher priority thanthe current process?NoContinue processRun its next FDE cycleYesSave current stateRegisters → stack12037Check sourceCall the matching ISRISR handles evente.g. “add paper” alert9002ISR = interrupt service routineAnother higher-priority interrupt?YesNoRestore saved stateStack → registersResume original process12037

What happens as a result?

  1. 1
    The ISR deals with the event: for example, the character for a key press is shown, or an alert is displayed.
  2. 2
    Any waiting interrupt with higher priority than the original process is serviced first.
  3. 3
    When 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.

Your turn

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?

  1. 1
    hardware (the battery is a device)
  2. 2
    the register values (the current state) are copied onto the stack
  3. 3
    the process carries on with its next FDE cycle; the interrupt waits in the queue
Tick what you can do now
Exam focusThe interrupt is the signal; the ISR is the routine that handles it. The current state is saved before the ISR runs and restored afterwards. If the interrupt is not higher priority, the current process carries on.
Practise with s26/11 Q4(d); m24/12 Q3(b) (older paper); s25/13 Q4(c) (older paper)
2 / 4
0478 · Unit 4 · Software
Revisionbyexamplicity

Programming languages and translators

§4.2 · 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.

AdvantagesDisadvantages
High-level
English-like, e.g. Python
  • easy to read, write and debug
  • machine independent (portable)
  • one statement can do many operations
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
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
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
hard to read, write and debug · machine specific: only works on one type of processor
Assembly language is a low-level language that uses mnemonics (e.g. 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.

Compilern = 4t = n *print(t)Whole source codeTranslate whole programError?YesReport errorsNoSave executableInterpretern = 4t = n *print(t)Read one statementTranslate and execute itError?YesStop; report errorNoNext statementstatement 1 runsstatement 3 never runs
Compilern = 4t = n *print(t)Whole source programTranslate whole programError?YesReport errorsNoSave executableInterpretern = 4t = n *print(t)Read one statementTranslate and execute itError?YesStop; report errorNoNext statementstatement 1 runsstatement 3 never runs
CompilerInterpreter
Translatesthe whole program at once, before it runsone statement at a time, executing each straight away
Errorsan error report for the whole code: errors can be fixed togetherstops at the first error; correct it before continuing
Outputan executable file: repeat tests without translating each time; the final program runs fasterno executable: translated every time it runs, which is slower
A suitable usedistributing the final program: users need no translator or source codetesting unfinished sections: the rest of the program need not work yet
Your turn

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.

  1. 1
    the compiler
  2. 2
    an interpreter: it runs one statement at a time, so the part already written can be tested and the rest need not work yet
  3. 3
    it can directly manipulate hardware, and may run faster and use memory more efficiently
Tick what you can do now
Exam focusDefine low-level as close to machine code: “uses mnemonics” is not a definition. Say “directly manipulate hardware” (or “communicate directly”), not just “communicates with hardware”. “Assembly” is a language; an “assembler” is the translator.
Practise with s26/11 Q5(a)–(c); s26/12 Q7(a)–(d); m26/12 Q9(b); s26/13 Q5(b); m25/12 Q7(b) (older paper); w25/12 Q3(a) (older paper)
3 / 4
0478 · Unit 4 · Software
Revisionbyexamplicity

Integrated development environments

§4.2 · Programming languages and translators

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.

scores.pyTranslate▶ Run561# add up three scores2total = 03for score in [4, 7, 9]:4 total = total + score5prnt(total)6pri4print(…)property(…)312code editorprettyprint:colour + indentsAuto-correctionprnt → printError diagnosticsLine 5: name 'prnt' is not definedthe line is highlighted7Run-time environment> 20output once the errors are fixed
Code editor: scores.py1# add up three scores2total = 03for score in [4, 7, 9]:4total = total + score5prnt(total)Error diagnosticsLine 5: name 'prnt' is not definedThe line is highlightedAfter correction: print(total)Run-time output: 204 + 7 + 9 = 20

Seven functions

The numbers match the marks on the IDE above. Say what each function does for the programmer.

FunctionHow it helps the programmer
1Code editora place to type and edit the source code, with line numbers
2Prettyprintcolour-codes key words (syntax highlighting) and indents code, so it is easier to read
3Auto-completionsuggests the rest of a key word or name as it is typed, saving time and typing errors
4Auto-correctioncorrects a mistyped word or name, e.g. prnt → print
5Translatora compiler and/or interpreter built in, to translate the code into machine code
6Run-time environmentruns the program inside the IDE so it can be tested, showing input and output
7Error diagnosticsidentifies 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).

Your turn

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.

  1. 1
    auto-correction
  2. 2
    prettyprint
  3. 3
    all the tools are in one place, so code can be written, run and tested without switching programs
Tick what you can do now
Exam focusDescribe what the feature does for the programmer: “auto-completion suggests the rest of a key word”. “Debugging” on its own is too vague, and the description must be specific, not generic.
Practise with s26/11 Q5(d); s26/12 Q7(e)
4 / 4