Book 1 · Chapter 5
System Software
B1·5This chapter is in the ebook.
Read it in full on cswithzak.com. Every question has its mark scheme and every program is ready to run. The free practice for each section is below, with the short code the book prints beside it.
For the whole chapter
- Topic pageSystem Software
B1·5·T - QuizSystem Software
B1·5·Q1 - LabCompiler stages & tokens
B1·5·X1 - LabScheduling simulator
B1·5·X2
§5.1 Operating systems
Short code B1·5·1
- FlashcardsFlashcards §5.1: Operating system, utilities & libraries
B1·5·F1 - Past-paper questionsPast-paper questions §5.1 (operating-systems)
B1·5·1
§5.2 Language translators
Short code B1·5·2
- FlashcardsFlashcards §5.2: Translators & IDEs
B1·5·F2 - Past-paper questionsPast-paper questions §5.2 (language-translators)
B1·5·2
Why a computer needs an operating system
Short code B1·5·10
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Memory management
Short code B1·5·11
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
File management
Short code B1·5·12
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Security management
Short code B1·5·13
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Hardware management
Short code B1·5·14
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Process management
Short code B1·5·15
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Utility software: what it is and why it is needed
Short code B1·5·16
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Disk formatter, defragmenter, disk analysis and repair
Short code B1·5·17
disk = "AAB.ACBB.AC.CA..."
def pieces(blocks, f):
count = 0
for i in range(len(blocks)):
prev = blocks[i - 1] if i > 0 else "."
if blocks[i] == f and prev != f:
count += 1
return count
def show(label, blocks):
counts = [f + "=" + str(pieces(blocks, f)) for f in "ABC"]
print(label, blocks, "|", ", ".join(counts))
show("Before:", disk)
files = sorted(b for b in disk if b != ".")
show("After: ", "".join(files) + "." * disk.count(".")). is a free block; the numbers count each file's pieces). Notice that the files hold exactly the same blocks afterwards: only their positions change, so each file can be read in one sweep.Output · 1 row
| Before: AAB.ACBB.AC.CA... | A=4, B=2, C=3 |
|---|---|
| After: AAAAABBBCCC...... | A=1, B=1, C=1 |
Virus checker, file compression and back-up
Short code B1·5·18
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Program libraries and DLLs
Short code B1·5·19
DECLARE FirstName : STRING
DECLARE LastName : STRING
DECLARE Username : STRING
DECLARE MinutesToday : INTEGER
FirstName ← "Sana"
LastName ← "Qureshi"
MinutesToday ← 100
Username ← MID(FirstName, 1, 1) & LastName
OUTPUT "Username: ", Username
OUTPUT "Letters: ", LENGTH(Username)
OUTPUT "Ends with: ", RIGHT(LastName, 3)
OUTPUT "Whole hours today: ", INT(MinutesToday / 60)MID, RIGHT, LENGTH and INT, all from the pseudocode guide. Sana wrote none of them, tested none of them, and still relies on them.Output
Username: SQureshi Letters: 8 Ends with: shi Whole hours today: 1
Translators: why programs need translating
Short code B1·5·20
DECLARE Total : INTEGER
DECLARE Reading : INTEGER
Total ← 18
Reading ← 21
Total ← Total + Reading
OUTPUT TotalOutput
39
100 LDD 200
101 ADD 201
102 STO 200
103 END
200 18
201 21Total ← Total + Reading written in assembly language: three instructions for one high-level statement (online; the trace is printed in spread 20).Output
OUTPUT: LDD 200 | ACC=18 | IX=0 | | ADD 201 | ACC=39 | IX=0 | | STO 200 | ACC=39 | IX=0 | 200=39 | END | ACC=39 | IX=0 | |
Compilers and interpreters: how each one works
Short code B1·5·21
program = ["total = 0",
"total = total + 25",
"print('Total so far:', total)",
"print('Average:' total / 2)",
"print('Finished')"]
print("Interpreter:")
memory = {}
for n, line in enumerate(program, 1):
try:
code = compile(line, "line", "exec")
except SyntaxError:
print(" error on line", n, "- stop")
break
exec(code, memory)
print("Compiler:")
try:
code = compile("\n".join(program), "prog", "exec")
print(" no errors - object code saved")
except SyntaxError as e:
print(" error on line", e.lineno, "- nothing saved, nothing run")compile does the translating. Notice that line 3 ran under the interpreter, but nothing ran under the compiler.Output
Interpreter: Total so far: 25 error on line 4 - stop Compiler: error on line 4 - nothing saved, nothing run
DECLARE Total : INTEGER
DECLARE Count : INTEGER
Total ← 0
Count ← 3
OUTPUT "Total so far: ", Total
Average ← Total / Count
OUTPUT "Average: ", AverageOutput
ERROR: Line 6: 'Average' has not been DECLAREd — add DECLARE Average : <TYPE> before using it
Choosing a translator: justify, don't describe
Short code B1·5·22
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Partly compiled, partly interpreted: Java and bytecode
Short code B1·5·23
public class Main {
public static void main(String[] args) {
int[] sessions = {25, 40, 15, 30};
int shortest = sessions[0];
for (int s : sessions) {
if (s < shortest) {
shortest = s;
}
}
System.out.println("Shortest session: " + shortest + " minutes");
}
}javac turns this source into bytecode in a .class file once; the Java Virtual Machine then interprets that bytecode on whatever computer runs it.Output
Shortest session: 15 minutes
The IDE: writing and presenting code
Short code B1·5·24
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
The IDE: debugging
Short code B1·5·25
DECLARE Sessions : ARRAY[1:4] OF INTEGER
DECLARE Index : INTEGER
DECLARE Shortest : INTEGER
Sessions[1] ← 25
Sessions[2] ← 40
Sessions[3] ← 15
Sessions[4] ← 30
Shortest ← 0
FOR Index ← 1 TO 4
IF Sessions[Index] < Shortest THEN
Shortest ← Sessions[Index]
ENDIF
OUTPUT "Watch: Index = ", Index, " Sessions[Index] = ", Sessions[Index], " Shortest = ", Shortest
NEXT Index
OUTPUT "Shortest session: ", Shortest, " minutes"Watch: line is what the report window shows when the program pauses there (online; the trace is printed in spread 25).Output
Watch: Index = 1 Sessions[Index] = 25 Shortest = 0 Watch: Index = 2 Sessions[Index] = 40 Shortest = 0 Watch: Index = 3 Sessions[Index] = 15 Shortest = 0 Watch: Index = 4 Sessions[Index] = 30 Shortest = 0 Shortest session: 0 minutes
DECLARE Sessions : ARRAY[1:4] OF INTEGER
DECLARE Index : INTEGER
DECLARE Shortest : INTEGER
Sessions[1] ← 25
Sessions[2] ← 40
Sessions[3] ← 15
Sessions[4] ← 30
Shortest ← Sessions[1]
FOR Index ← 2 TO 4
IF Sessions[Index] < Shortest THEN
Shortest ← Sessions[Index]
ENDIF
NEXT Index
OUTPUT "Shortest session: ", Shortest, " minutes"Shortest at the first session, not at 0, and compare from the second. Now the report window would show Shortest change at Index 3.Output
Shortest session: 15 minutes
Workbook 1: System Software
Short code W1·5 · Theory Fundamentals Workbook
The write-in workbook for this chapter has drills, exam-style practice, trace tables, fix-the-mistake and mark-it-yourself pages. Its full mark schemes and an interactive version arrive here with the chapter.


