Skip to content

9618 · Unit 5 · Paper 1: Theory fundamentals

System software.

9618 · Unit 5 · System software
Revisionbyexamplicity

Why a computer needs an operating system

§5.1 · Operating systems · purpose of an OS

Without an operating system, every app on a tablet would have to drive the screen, the disk and the network by itself. The operating system (OS) does that work once, for all of them. It is system software that controls the hardware and provides a platform on which application programs run.

Read the drawing from the top down: the user works with applications, the applications ask the OS, and only the OS works the hardware beneath it.

UserWeb browserWord processorStudent’s programOperating systemMemorymanagementFilemanagementSecuritymanagementHardwaremanagementProcessmanagementProcessorRAMStoragePeripherals
Useruser interfaceApplicationsweb browser · word processor · student's programOS servicesOperating system: manages resourcesMemory managementFile managementSecurity managementHardware managementProcess managementdevice driversHardwareprocessor · RAM · storage · peripheralsApplications use services; the OS hides device details.

The purpose and what it allows

Picture one tablet running a game and a chat app at the same time. Each purpose of the OS lets the user or the apps do something: be able to name each one and say what it allows.

OS purposeWhat this lets the tablet do
Provides a user interfacelets its user communicate with the hardware through a GUI or command line
Provides a platform for applicationslets the game and chat app call OS services instead of driving devices themselves
Manages memorykeeps the data of both apps in RAM, protected from each other
Manages processesshares processor time fairly, so both apps can make progress
Manages files and peripheralslets the user save files and exchange data with devices
Identify: name the task, such as memory management. Describe: add its action, such as allocating separate areas of RAM to the game and chat app. Purpose: connect the action to what it allows.
System software runs and maintains the computer: the OS, utility programs and language translators. Application software performs a task for the user, such as writing a letter.
Your turn

1 Which two of these are system software: a compiler, a spreadsheet, a defragmenter, a game?

2 The chat app shows a photo by asking the OS to draw it, not by driving the screen itself. Which purpose of an OS is this?

3 Describe one task the OS does so that the game and the chat app can run at the same time.

  1. 1
    the compiler and the defragmenter (a translator and a utility)
  2. 2
    it provides a platform for applications: the app calls an OS service
  3. 3
    for example: memory management gives each app its own area of RAM and stops one reading the other’s; or process management gives each app turns on the processor
Tick what you can do now
Practise with s25/11 Q6(b); w25/13 Q8(d); s26/13 Q5(a)(ii)
1 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Memory and process management

§5.1 · Operating systems · key management tasks

A laptop can play music while you write an essay (multitasking), yet it has one RAM and one processor for every program to share. Memory management decides where each process is held in RAM; process management decides when each process uses the processor.

Memory management: where each process is held

Each row is the same 16 blocks of RAM at a different moment. Compare the two rows: B’s blocks are freed, D takes the first gap that fits, and the red line marks where A must stop.

0123456789101112131415A, B and C runningeach has its own blocksOSABCfreeB closes, D startsB’s blocks reused by DOSADfreeCfreeA may not write past this boundary into D’s blocksD is given the first free blocks that fit
A, B and C running0123456789101112131415OSABC·Each process has its own blocks of RAM.B closes; D starts0123456789101112131415OSAD·C·D reuses blocks 8–9; · marks free space.Protection prevents A overwriting D's blocks.
  • Allocates each process the blocks of RAM it needs, when it needs them
  • Protects private memory: a process cannot access or overwrite another process's private area
  • Takes blocks back when a process ends
  • Moves data between RAM and disk as needed (virtual memory)

Process management: when each process runs

Read along the time arrow: the processor runs one process at a time, and each pause is the end of a time slice.

Processor timeone time slice each, in turnA runsB runsA pausedC runsB pausedA runsC pausedB runsA pausedA runsB pausedtime
One processor: one process per time slice1A2B3C4A5B6Atime → pause one process, run the next
  • Schedules: picks the next process to run, by priority
  • Gives each process a time slice, pausing the others
  • Moves processes between ready, running and waiting
  • Shares out resources, settles clashes and lets processes exchange data
  • Handles interrupts so a process can respond to an event
On the laptop, memory management keeps the music, essay and virus scanner in protected RAM areas. Process management pauses and resumes them, choosing which runs next. The RAM areas are places; the time slices are turns.
Your turn

1 The OS takes back a program’s blocks of RAM when it closes. Is this memory management or process management?

2 In the second row of the memory figure, a new process E starts and needs 3 blocks. The OS gives it the first free blocks that fit. Which blocks does E get?

3 Why does “it allows multitasking” not describe a task of process management?

  1. 1
    memory management: it decides where processes are held
  2. 2
    blocks 13 to 15: block 10 is free but only one block long
  3. 3
    it is a result, not an action; a task says what the OS does, such as giving each process a time slice
Tick what you can do now
Exam focusGive tasks, the actions (“gives each process a time slice”), not results: “allows multi-programming” earns nothing. Freeing memory is memory management; choosing which process runs next is process management.
Practise with s26/12 Q7(a)(i), (a)(ii); s24/12 Q6; w24/12 Q3(c)
2 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

File management and security management

§5.1 · Operating systems · key management tasks

A disk holds thousands of files, and the computer must find any one of them at once. File management organises how files are stored on, and found in, secondary storage. Not every user should reach every file: security management stops unauthorised access and makes it possible to recover lost data.

File management

Find essay.txt in the folder tree, then in the table: its letter E fills units 2, 3, 4 and 9, so one file can be split across the disk.

Directory structureC: (root)Documentsessay.txtphoto.pngProgramsgame.exeSecondary storage divided into allocation unitsT0T1E2E3E4P5P6P7P8E9G10G11G12131415File allocation table (T): which units belong to which fileessay.txt2, 3, 4, 9photo.png5, 6, 7, 8game.exe10, 11, 12free13, 14, 15space is allocated to each file;unallocated units are marked freeso they can be used again
Directory tree: find a file by its folderC: (root)Documentsessay.txtphoto.pngProgramsgame.exeAllocation units: the table records each file0T1T2E3E4E5P6P7P8P9E10G11G12G13·14·15·T = allocation table · E = essay · P = photoG = game · · = free units (13, 14, 15)
  • Splits secondary storage into allocation units and records which units hold each file
  • Builds and keeps the folder (directory) tree
  • Sets the file system, e.g. FAT or NTFS
  • Sets the rules for file names
  • Controls who can open, edit or share a file
  • Offers file operations: create, open, close, copy, move, rename, delete, search

Security management

Follow one request along the arrows: it is refused at the first check it fails, and only an allowed action reaches the log.

Requestopen essay.txtAuthenticationuser ID and passwordAccess rightsmay this user read it?Allowedaction logged (audit)identity not confirmed: refusedno permission: refused
Requestopen essay.txtAuthenticationuser ID and passwordIdentity fails→ refusedAccess rightsmay this user read it?No permission→ refusedAllowedaction logged for auditing
  • Checks who is asking: authentication of users and processes
  • Sets who may do what: access rights and permissions
  • Provides for recovery of lost data
  • Applies OS security updates as they are released
  • Logs activity, so it can be checked later (auditing)
  • Creates user accounts and passwords; runs a firewall and anti-malware
Some tasks fit under more than one heading: controlling access rights belongs to file management and to security management. Answer under the heading the question names.
Your turn

1 Use the file allocation table. Which allocation units hold photo.png?

2 essay.txt is deleted. Which units are now marked free?

3 A user signs in with the right password but has no permission to edit a file. At which step of the security figure is the edit refused?

  1. 1
    5, 6, 7, 8
  2. 2
    2, 3, 4, 9, 13, 14, 15: essay’s units go back to the free list
  3. 3
    access rights: authentication passed, but this user may not edit the file
Tick what you can do now
Exam focusDescribe the action the OS takes: “splits storage into allocation units and assigns them to files”; “builds the folder tree”. For security, say how: “refuses a user whose identity it cannot confirm”.
Practise with w24/11 Q4(a)(i); w25/11 Q5(a)(ii)
3 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Hardware management

§5.1 · Operating systems · hardware management

A program that prints a page should not need to know how that printer works. Hardware management (input/output or peripheral management) lets programs use devices without knowing how each one works. Printing uses all three of its mechanisms: a driver, a buffer and an interrupt.

Follow the essay along the arrows: the driver turns it into printer commands, the buffer holds it while the slow printer works, and the interrupt asks for more.

Application“Print essay”Operating systemPrinter driverturns the data into theprinter’s own commandsBufferdata waits herePrinterprints slowlyinterrupt: “buffer empty, send more” or “out of paper”
ApplicationPrint essayOperating system: printer driverturns application data intothe printer's commandsBuffer: data waits herePrinteruses the data slowlyInterrupt back to OS: buffer empty → send moreor out of paper → deal with the problem

What hardware management does

Without the OS, every program would have to handle each device’s speed, signals and power itself. Be able to give each task with its purpose: the task is what the OS does, the purpose is why.

Hardware management taskPurpose
Loads the device driver for each devicethe computer cannot talk to a device without its driver
Passes data between programs and devicese.g. pages out to a printer, key presses in from a keyboard
Holds data in a buffer on the waya keyboard, a disk and a printer each work at their own speed
Responds to interrupts (signals) from devicesa device reports that it is ready, finished or in trouble
Hides the differences between devicesa program prints the same way on any printer
Manages poweruses sleep states, processor throttling and battery controls to reduce power use

Which management task is it?

The OS…Management task
stops the chat app reading the game’s part of RAMmemory management
starts the driver when a USB camera is plugged inhardware management
confirms who a user is before letting them sign insecurity management
decides whether the music or the virus scan gets the processor nextprocess management
records which disk units are still freefile management
Your turn

Which OS management task is each of these? The OS…

1 stops the chat app reading the game’s part of RAM.

2 starts the driver when a USB camera is plugged in.

3 confirms who a user is before letting them sign in.

4 decides whether the music or the virus scan gets the processor next.

5 records which disk units are still free.

6 Why does the OS hold the essay in a buffer on its way to the printer?

  1. 1
    memory management
  2. 2
    hardware management
  3. 3
    security management
  4. 4
    process management
  5. 5
    file management
  6. 6
    the printer works much more slowly than the processor; the data waits in the buffer, and the printer sends an interrupt when it needs more
Tick what you can do now
Exam focusExpand each task with a reason: loads device drivers … because each device needs its own commands; uses buffers … because the processor and the device run at different speeds.
Practise with w25/11 Q5(a)(i); s26/13 Q5(a)(i); w22/13 Q3 (older paper: matching)
4 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Utility software

§5.1 · Operating systems · utility software

Like a car, a computer needs looking after, or it slows down and loses work. A utility program sets up, configures, analyses, optimises or maintains the computer. It is optional: the user or the OS starts it when a maintenance job needs doing.

Each utility at work

The strip on each card shows the disk or file before and after. Read it, then say what the utility does and why it is needed.

Disk formatter

ABACBCT
What it does

Prepares a disk for use: checks it for errors and writes a new file system (directory and allocation table); can make partitions.

Why it is needed

A disk cannot store files until it has a file system. Formatting erases the files on it.

Disk contents analysis / disk repair

AA×ABBbad sector marked; skipped
What it does

Finds disk errors and marks bad sectors so they are skipped; recovers damaged files where it can.

Why it is needed

Power loss or damage can corrupt files and spoil parts of the disk.

Defragmentation

ABACAAAABC
What it does

Puts each file’s blocks into one contiguous run and joins the free space.

Why it is needed

Files end up in fragments; the disk head must move between them, so reads are slower.

Virus checker

AB!CDEevery file scanned; virus removed
What it does

Scans files and memory for malicious code and removes it.

Why it is needed

New viruses appear all the time, so it needs frequent updates and regular scans.

File compression

1818181818, 4
What it does

Reduces the size of a file. Text and program files need lossless compression, such as run-length encoding.

Why it is needed

Saves storage space and cuts transmission time.

Back-up

ABCABCcopy, kept elsewhere
What it does

Copies data on a schedule, without the user starting it.

Why it is needed

If data is lost or damaged, the copy restores it.

Lossless compression: a sensor log

A weather station repeats the same reading. Run-length encoding (RLE) stores each run as its value once and the number of repeats:

18 18 18 18 → (18, 4)

Decoding restores all four readings, so no data is lost.

Do not confuse

A formatter prepares a disk and wipes it; disk repair fixes a disk already in use. A back-up is a copy kept in case the original is lost; it does not stop the loss.

Your turn

1 Every night, a school’s files are copied to another drive without anyone starting the job. Which utility is this?

2 A sensor logs 21 21 21 21 21 19 19. Write the log in run-length encoding.

3 A student formats a USB drive that holds their coursework. What happens to the coursework?

  1. 1
    back-up: it copies data on a schedule
  2. 2
    (21, 5) (19, 2): each value once, with how many times it repeats
  3. 3
    it is erased: formatting writes a new, empty file system
Tick what you can do now
Practise with s26/13 Q5(b)(i), (b)(ii); w24/11 Q4(a)(ii); w22/11 Q7(c) (older paper: compression)
5 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Defragmentation and performance

§5.1 · Operating systems · utility software

A computer that opened files at once when it was new can feel slow a year later. Part of the reason is on its hard disk. Each file is stored in blocks, and as files are saved, deleted and extended, one file ends up in different places. The read-write head must move between them.

The same 16 blocks at three moments, top to bottom: after saving, after deleting and extending, then after defragmenting. Follow the orange arrow to see the extra trip the head makes for file A.

01234567891011121314151 Files A, B, C savedeach file is contiguousAAAABBCCC2 B deleted, D saved,A extended: A and D splitAAAADDCCCDAA3 After defragmentingevery file contiguousAAAAAACCCDDDthe head must move from block 3 to block 10 to read the rest of Afree space collected together
1 Files A, B and C saved0A1A2A3A4B5B6C7C8C91011121314152 B deleted; D saved; A extended0A1A2A3A4D5D6C7C8C9D10A11A12131415A needs a head move: block 3 → block 103 After defragmenting0A1A2A3A4A5A6C7C8C9D10D11D12131415After: every file contiguous; free space together.

Why defragmenting makes files open faster

Each link leads to the next. An “explain” answer gives every link, ending at faster access.

Utilities that improve performance

Defragmenting is not the only utility that speeds a computer up. Two others help in different ways.

UtilityHow it improves performance
Defragmentationeach file is in one run, so the head moves less and files open sooner
Disk repair / contents analysisbad sectors are marked and skipped, so data is not written to them
Virus checkermalware that runs in memory is removed, so more RAM is free for programs
The head-movement reason applies to a hard disk. A solid-state drive has no moving head, so defragmenting it gives no saving in head movement.
Your turn

1 In row 2 of the figure, how many separate pieces (fragments) is file D in?

2 After defragmenting (row 3), which blocks hold file A?

3 Why does defragmenting a solid-state drive not make files open faster?

  1. 1
    2: blocks 4–5 and block 9
  2. 2
    blocks 0 to 5, one contiguous run
  3. 3
    it has no read-write head to move, so joining the pieces saves no head movement
Tick what you can do now
Exam focus“Explain” needs the chain, not the process alone: files made contiguous → less head movement → faster access. A description of the process with no link to access time scores nothing.
Practise with s26/12 Q7(a)(iii); w21/12 Q7(c) (older paper: other performance utilities)
6 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Program libraries

§5.1 · Operating systems · program libraries

Why write a sort again when one is already written and tested? A program library is a set of pre-written (pre-tested, often pre-compiled) routines. A program imports the library, then calls its routines.

Follow each call along its arrow: the student’s program only names the routine; the code that runs is in the library.

Student’s program (source code)Mean ← Average(Scores)CALL SortList(Scores)Spread ← SquareRoot(Variance)Statistics librarypre-written · pre-tested · documentedAverage(…)SortList(…)SquareRoot(…)Median(…)library imported;routines calledthe routines arenot rewritten
Import Statistics, then call its routinesMean ← Average(Scores)callsAverage(…) in the libraryCALL SortList(Scores)callsSortList(…) in the librarySpread ← SquareRoot(Variance)callsSquareRoot(…) in the libraryRoutine bodies are not rewritten in the program.Median(…) is available but not called here.

Benefits of library routines: point, then because

Each benefit has its reason. In an answer, give the benefit, then the “because”.

Benefit to the programmer… because
Saves programming timethe routine already exists, so the programmer starts from it, not from nothing
Saves testing time; more robustthe routine has been tested and comes with documentation, so it is likely to work
Harder tasks are within reachthe programmer calls a routine they could not easily code themselves
Another language’s strengthsa routine written in a different language can use that language’s features
Shorter, more readable sourceone call by name replaces the whole routine
Upgrades arrivean improved routine is used by programs that link to it at run time (see DLLs)

A library made by the team

  • Team members call each other’s routines instead of rewriting them.
  • A new program starts from routines already written: continuity from one program, and one programmer, to the next.
  • Each member writes the routines they do best (their specialism); the others call them.

Drawbacks

  • Compatibility: a routine written for another data format or language version fails when the program passes it different input.
  • A routine that does nearly, but not exactly, the job must be edited, then tested again.
  • A changed library routine can change a program’s results with no change to the program’s own code.
Your turn

1 Give the two ideas that define a library routine.

2 A programmer calls SortList from the statistics library instead of writing a sort. Give one benefit, with its reason.

3 The library’s Average routine is changed. The student’s program now prints a different mean, though its own code is unchanged. Which drawback is this?

  1. 1
    it is pre-written (and pre-tested), and it is called from another program once the library is imported
  2. 2
    for example: it saves testing time, because the routine has already been tested; or it saves programming time, because the routine already exists
  3. 3
    a changed library routine can change a program’s results with no change to the program’s own code
Tick what you can do now
Exam focusDefine the term with two ideas: pre-written routines, and called from another program once the library is imported. Give each benefit its reason: less testing because the routine has been tested already.
Practise with s24/13 Q7(e)(i); w24/11 Q4(c); w24/12 Q4(b); w25/11 Q5(b)(i), (b)(ii)
7 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Language translators

§5.2 · Language translators · assembler, compiler, interpreter

People write programs in words and symbols, but a processor executes only machine code. So source code must be translated first. An assembler translates assembly language; a compiler or an interpreter translates a high-level language.

Read each row along its arrows: what goes in, the translator, and what comes out. The note at the end of each row says what happens to an error.

Assembly languageAssemblerMachine codeone machine-code instruction for each assembly instructionrun later, without theassemblerHigh-level source codeCompilerExecutable filewhole program translated before it runssyntax errors listed together;no executable until correctedHigh-level source codeInterpreterEach line executedeach line read, translated, executedstops at the first error;no translated file is kept
AssemblerAssembly language → machine codeOne machine instruction per assembly instructionThe machine code runs later without the assembler.CompilerHigh-level source → executable fileTranslate the whole program before it runs.Syntax errors listed; correct them before running.InterpreterHigh-level source → each line executedRead, translate and run one line; then the next.Halt at an error; no translated file is kept.

What each translator does with an error

The two translators behave very differently when a program has a mistake in it. Give each one the same faulty program, and be able to say what it does.

Line 7: a misspelt keyword
1DECLARE Price, Total : INTEGER
2Total ← 0
3FOR Price ← 10 TO 30 STEP 10
4Total ← Total + Price
5OUTPUT "Total: ", Total
6NEXT Price
7OUPTUT "Final: ", Total

Compiler

Reads and checks all seven lines first, then reports the error in line 7 (with any others) in one list. No executable is produced, so nothing runs: there is no output.

Interpreter

Translates and runs lines 1 to 6 in turn, so this is output first:

Total: 10
Total: 30
Total: 60

It stops at line 7 and shows the error. Once it is corrected, it continues from line 7.

Your turn

1 Which translator turns assembly language into machine code?

2 Line 3 is changed to FOR Price ← 10 TO 30 STEP 20; line 7 is still misspelt. What does the interpreter output before it stops?

3 What does the compiler output for that program, and why?

  1. 1
    an assembler
  2. 2
    Total: 10 then Total: 40: Price takes 10, then 30, and it stops at line 7
  3. 3
    nothing: it checks the whole program first, reports the error in line 7 and makes no executable
Tick what you can do now
Exam focusDescribe each operation precisely. A compiler checks all the source code before anything runs, lists syntax errors together, and writes an executable file once these are corrected. An interpreter takes one line at a time, translates and runs it, and halts at an error.
Practise with s26/11 Q2(a), (c); s25/13 Q3(a)
9 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Compiler or interpreter?

§5.2 · Language translators · benefits, drawbacks and justification

While you write a program, you want to try each part as soon as it is typed. Once it is finished, you want one fast file to hand out. So an interpreter suits a program that is still being written, and a compiler suits one that is finished. Compare the two on the same aspect each time.

1 While the program is written and testedprogrammerInterpreterruns each part as soon asit is typed; halts at a fault2 Once it is finished and given to usersCompilertranslates thewhole program onceExecutable fileruns with notranslator or sourceusersdevelopment time →
1 While it is written and testedprogrammerInterpreterruns each part as soon asit is typed; halts at a fault2 Once it is finished and given to usersCompilertranslates thewhole program onceExecutable fileruns with notranslator or sourceusers

Benefits and drawbacks, point by point

Read across one row at a time: each row compares the two on one aspect, so you can set the two against each other.

InterpreterCompiler
Finding errorshalts at the faulty line, so you see where it is; later lines are not reported, so no dependent errorslists syntax errors after a full pass; one mistake can trigger false reports on later lines
Correcting errorsfix the line and carry on from it; each change shows its effect at oncefix, then compile the whole program again before it can run
Unfinished codea half-written program can be run and testedwill not build while a syntax error remains
A large programstarts running at once, line by linenothing runs until the whole compile has finished
Running againeach line is translated afresh on every runthe executable reruns with no translation, and faster
Giving it to usersusers need the interpreter and the source codeusers get an executable alone: no translator, and the source stays hidden, so users cannot read or change it

Justify the choice for the stage

Naming a translator does not justify it. Link its feature to what the programmer needs at that stage.

Worked question

A programmer is writing a revision quiz app for a school. Explain how the programmer uses an interpreter, and later a compiler, during its development.

  1. +1
    While the quiz is being written, use the interpreter
  2. +1
    … run and test each part as it is added, fixing each error where it halts
  3. +1
    Once the quiz is finished, use the compiler
  4. +1
    … it makes one executable file that reruns without retranslating and can be handed to the school without its source code
Your turn

1 Which translator lets a half-written program be run and tested?

2 A games company sells its finished game and does not want players to read its code. Which translator should it use for the copy it sells? Give a reason.

3 A compiler reports errors on lines 8, 9 and 12. Only line 8 is wrong. Why are the others reported?

  1. 1
    an interpreter: it runs each line as it reaches it
  2. 2
    a compiler: players get an executable file only, so the source code stays hidden
  3. 3
    one mistake can trigger false reports on later lines that depend on it (dependent errors)
Tick what you can do now
Exam focusJustify by the stage of development: an interpreter while the program is written and tested, a compiler once it is finished and ready to give to users. Naming a translator without linking it to the stage earns nothing.
Practise with s26/11 Q2(b); s24/11 Q3(a), (b); w25/13 Q8(a); w25/12 Q10(a)
10 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Partial compilation and interpretation

§5.2 · Language translators · Java

A games studio wants one game file that runs on Windows, Apple and Linux computers, each with a different processor. Java makes that possible because it is partially compiled and partially interpreted: the compiler produces bytecode, intermediate code that is not the machine code of any one processor.

Follow the bytecode: the developer compiles it once, then each platform’s own virtual machine turns it into machine code for its processor.

1 Compiled once, before distributionJava sourcehigh-level codeCompilerrun by the developerBytecodeintermediate codethe same bytecode filefor every platform2 Interpreted into machine code when runVirtual machine (JVM)Windows laptop’s processorVirtual machine (JVM)Apple computer’s processorVirtual machine (JVM)Linux desktop’s processor
Java sourcehigh-level codeCompilerrun once by the developerBytecodesame intermediate file for every platformPlatform's virtual machine (JVM)Windows laptop's processorPlatform's virtual machine (JVM)Apple computer's processorPlatform's virtual machine (JVM)Linux desktop's processorEach JVM produces its processor's machine code.

Why do it this way?

Each feature of the two-stage design solves a problem for the studio. Give the feature, then why it helps.

FeatureWhy it helps the developer
One intermediate bytecode fileeach platform's virtual machine interprets it, so the same game can run on different platforms
Machine code made at run timeit can be optimised for the processor in use
Source compiled oncethe source-to-bytecode translation is not repeated on each run, reducing translation work

Four ways to translate, compared

The approach decides what you hand to the user and how quickly the program starts. Be able to say, for each approach, what it translates, when, and what a user needs to run the program.

ApproachTranslatesWhenNeeded to run the program
Assemblerassembly language → machine codebefore runningthe machine code only
Compilerhigh-level → executable (object code)before running, all at oncethe executable only
Interpreterhigh-level, line by linewhile runningsource code + interpreter
Partial (Java)high-level → bytecode → machine codecompiled before; interpreted while runningbytecode + virtual machine

Assembler

Translatesassembly → machine code
Whenbefore running
To runmachine code

Compiler

Translateshigh-level → executable
Whenwhole program before running
To runexecutable

Interpreter

Translateshigh-level, line by line
Whenwhile running
To runsource + interpreter

Partial (Java)

Translateshigh-level → bytecode → machine code
Whencompile before; interpret at run time
To runbytecode + virtual machine
Your turn

1 What is bytecode?

2 Why can the same bytecode file run on a Windows laptop and on a Linux desktop?

3 What must a user have to run a Java game?

  1. 1
    intermediate code made by the compiler: not the machine code of any one processor
  2. 2
    each platform has its own virtual machine, which interprets the bytecode into that processor’s machine code
  3. 3
    the bytecode and a virtual machine for their platform
Tick what you can do now
Exam focusThe question asks why: give a reason with its cause, such as portability (“one bytecode file runs on every platform, because each one’s virtual machine interprets it”). Describing the two stages earns nothing on its own.
Practise with s26/12 Q7(b)(ii)
11 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

IDE features for writing code

§5.2 · Language translators · integrated development environment

Writing code in a plain text editor means hopping between separate tools to translate it, run it and fix it. An integrated development environment (IDE) brings together the tools to write, translate, run and debug a program in one application, and its editor helps while you type.

Match each numbered note to the editor window: every number names one feature you can see working on the code.

Marks.pse · editor1DECLARE Marks : ARRAY[1:5] OF INTEGER2DECLARE Index, Total : INTEGER3Total ← 0 // running total4FOR Index ← 1 TO 55 Total ← Total + Marks[Index]6NEXT Index7IF Total > 50syntax error: THEN expected8 OUTPUT "Pass"9ENDIF10OUTPUT TotTotal : INTEGERline 21Prettyprintkeywords, strings and commentsare shown in different colours2Expand and collapsethe arrow hides or shows thelines of the FOR block3Dynamic syntax checkthe error is underlinedas soon as the line is typed4Context-sensitive promptsuggests identifiers and keywordsthat fit at this point
Marks.pse · editor1DECLARE Marks : ARRAY[1:5] OF INTEGER2DECLARE Index, Total : INTEGER3Total ← 0 // running total4FOR Index ← 1 TO 55 Total ← Total + Marks[Index]6NEXT Index7IF Total > 508 OUTPUT "Pass"9ENDIF10OUTPUT TotLine 7: THEN expected → syntax checkLine 10 prompt: Total : INTEGER

Features by purpose

Each feature helps with one job: writing the code, catching errors early or making it easy to read. Learn them in those three groups.

PurposeFeatureHow it helps the programmer
CodingContext-sensitive promptsshows the words that can follow at this point, so there is less to type and remember
Auto-completefinishes the word being typed
Auto-correctfixes a misspelt word
Initial error detectionDynamic syntax checksmarks a rule break in a line as soon as the line is entered
PresentationPrettyprintcolours keywords, strings and comments differently, so the structure shows and slips stand out
Expand and collapse code blocksfolds away blocks not being worked on, so the overall shape is visible with less scrolling
Auto-indentationsets each block’s indent as it is typed, so the structure is clear
Give a different feature for each purpose, and a description that fits it. If the question rules out translators, naming a compiler or interpreter earns nothing.
Your turn

1 Which feature underlines line 7 as soon as it is typed?

2 While line 10 is typed, the editor shows Total : INTEGER. Which feature is this, and how does it help?

3 THEN is added to line 7. The marks are 8, 9, 10, 11, 12. What is output?

  1. 1
    a dynamic syntax check
  2. 2
    a context-sensitive prompt: it suggests an identifier that fits at this point, so there is less to type and remember
  3. 3
    nothing: Total is 50, and 50 > 50 is false, so line 8 does not run
Tick what you can do now
Exam focusName the feature and say what it does: a dynamic syntax check “underlines a rule break as the line is typed”. “Helps the programmer” is not a description.
Practise with s24/12 Q8(b); w24/11 Q4(d)(i); w25/11 Q5(c)
12 / 13
9618 · Unit 5 · System software
Revisionbyexamplicity

Debugging with an IDE

§5.2 · Language translators · integrated development environment

The hardest mistakes give no error message: a program can run and still output the wrong total. Debugging tools let you watch the program run, one line at a time, until the faulty line gives itself away.

Three debugging tools

Each tool shows a different part of the run, so you pick the one that answers your question. Be able to say what the programmer does with each one and what it shows.

ToolHow the programmer uses it
Breakpointhalts the program at a chosen line; the variables and the path taken so far can be inspected
Single steppingruns one line, pauses and waits: read the values and see which line comes next, then step again
Report windowa watch window: lists variables and their values, arrays and expressions included, updated as each line runs

Use the tools to find the wrong condition

The program should add five marks, 12 + 15 + 9 + 14 + 10 = 60, but it outputs 50. Use the tools in the numbered order to find out why.

Should output the total of five marks
 1DECLARE Marks : ARRAY[1:5] OF INTEGER
 2DECLARE Index, Total : INTEGER
 3// Marks holds 12, 15, 9, 14, 10
 4Total ← 0
 5Index ← 1
 6WHILE Index < 5
 7Total ← Total + Marks[Index]
 8Index ← Index + 1
 9ENDWHILE
10OUTPUT "Total: ", Total
  1. 1
    Set the breakpoint before line 10, then run: inspect Index = 5 and Total = 50.
  2. 2
    Restart and single step the last loop test while watching Index: 5 < 5 is false, so the fifth mark is skipped.
  3. 3
    Change the condition to Index <= 5, rerun, and check that Total is 60.

Report window, single stepping through the loop

PassIndexMarks[Index]Total
111212
221527
33936
441450

At the breakpoint (line 10)

Execution pauses before the output. The report window shows Index = 5, Total = 50: only four marks were added, so Marks[5] was never used. The condition should be Index <= 5; then the total is 60.

1
Set the breakpoint before line 10, then run: inspect Index = 5 and Total = 50.
2
Restart and single step the last loop test while watching Index: 5 < 5 is false, so the fifth mark is skipped.
3
Change the condition to Index <= 5, rerun, and check that Total is 60.

Watch the loop run, one line at a time

Follow Total and Index down their columns: the last mark goes missing at the final test. Each row is what the report window shows after one line runs, so be able to fill in a row like this.

Single step pass 4, the last time round the loop
Each line that runs is a row. Its value goes in that variable’s column: the blue row of the whole run below.
LineStatement that runsTotalIndexOutputWritesWhat happens
6WHILE Index < 5test 4 < 5 is true, so lines 7 and 8 run
test 4 < 5 is true, so lines 7 and 8 run
7Total ← Total + Marks[Index]50Total 5036 + Marks[4] = 36 + 14
36 + Marks[4] = 36 + 14
8Index ← Index + 15Index 54 + 1
4 + 1
6WHILE Index < 5test 5 < 5 is false: the loop ends before Marks[5] is added
test 5 < 5 is false: the loop ends before Marks[5] is added

The whole run: one row each time round the loop

TotalIndexOutputWhat decided it
start01lines 4 and 5 set the starting values
lines 4 and 5 set the starting values
pass 11221 < 5 is true: add Marks[1] = 12
1 < 5 is true: add Marks[1] = 12
pass 22732 < 5 is true: add Marks[2] = 15
2 < 5 is true: add Marks[2] = 15
pass 33643 < 5 is true: add Marks[3] = 9
3 < 5 is true: add Marks[3] = 9
pass 45054 < 5 is true: add Marks[4] = 14
4 < 5 is true: add Marks[4] = 14
endTotal: 505 < 5 is false: the loop ends, so Marks[5] is never added
5 < 5 is false: the loop ends, so Marks[5] is never added
Your turn

1 Which tool pauses the program at one chosen line?

2 Marks holds 10, 10, 10, 10, 10. What does the faulty program output?

3 With the condition changed to Index <= 5, how many times does the loop run?

  1. 1
    a breakpoint
  2. 2
    Total: 40: only the first four marks are added
  3. 3
    5 times: Index takes 1 to 5, and the test fails when Index is 6
Tick what you can do now
Exam focusDescribe what is done with the tool and what is read: the variable values and the flow at that line. A tool’s name on its own is not an explanation.
Practise with s26/12 Q7(b)(i); w24/12 Q4(a); w24/11 Q4(d)(ii)
13 / 13