Cambridge AS & A Level9608

System software (3.4)

Computer Science 9608 Chapter Notes

What this chapter covers

System software
ShareWhatsAppPost
System software (3.4) notes

Unable to load PDF

The notes viewer could not load. Please refresh the page.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full System software (3.4) notes as text: skim, search, and jump between subtopics.

~18 min read

1. The Operating System: The Computer's Manager

An operating system (OS) is the most important piece of system software on a computer. It acts as a master controller, managing all the computer's hardware and software resources. Think of it as an intermediary: it sits between you (the user) and your applications, and the physical hardware components. Without an OS, you would need to manually control every aspect of the hardware, which is incredibly complex. The OS provides a user interface to interact with the computer, such as a Graphical User Interface (GUI) with icons and windows, or a Command-Line Interface (CLI) where you type commands. Its main jobs include managing memory, scheduling which programs get to use the processor (CPU), handling input and output devices, organising files on storage drives, and maintaining system security.

Key term

Operating System (OS): A set of programs that manages computer hardware resources and provides common services for application software.

Examiner insight

Examiners expect students to identify and briefly explain at least three distinct management tasks. High-scoring answers will clearly separate functions like memory, processor, and file management.

Common pitfall

Simply stating 'the OS manages the computer' is too vague for an exam answer. You must name and describe specific management functions like memory management, process scheduling, or file management.

Fun fact

The first recognizable operating system, GM-NAA I/O, was created in 1956 by General Motors for its IBM 704 computer. Before this, programmers had to manually load their programs and control the hardware directly using switches.

Worked example 16 marks

Identify and explain briefly three management tasks carried out by an operating system. [6]

  1. 1
    1. Memory Management: The OS manages the computer's main memory (RAM). It allocates memory to processes that need it and deallocates it when they are finished. It also ensures that one process cannot interfere with the memory space of another, which is called memory protection.
  2. 2
    1. Processor (CPU) Management/Scheduling: In a multitasking system, many processes compete for CPU time. The OS scheduler decides which process gets to use the CPU and for how long. This ensures the CPU is used efficiently and the system remains responsive.
  3. 3
    1. File Management: The OS provides a logical view of information storage. It allows users to create, save, delete, and move files. It manages where files are physically stored on a disk and provides a directory/folder structure to keep them organised. It also controls access rights to files.

Worked example 24 marks

Name two different types of user interface an operating system can provide and identify a suitable input device for each. [4]

  1. 1
    1. Interface Type 1: Graphical User Interface (GUI). This interface uses windows, icons, menus, and pointers (WIMP). A suitable input device is a mouse or a touchscreen.
  2. 2
    1. Interface Type 2: Command-Line Interface (CLI). This interface requires the user to type text-based commands. A suitable input device is a keyboard.

Recap

  • An operating system is system software that manages all hardware and software resources.
  • The OS acts as an intermediary between the user and the computer's hardware.
  • Key OS functions include memory, processor, file, and device management.
  • The OS provides a user interface, such as a GUI or a CLI, for user interaction.
  • Without an OS, using a modern computer would be practically impossible for most users.
  • Security management, such as user authentication and access control, is also a critical OS task.

Quick check

  1. What is the primary purpose of an operating system?1 mark
  2. List two key management tasks performed by an OS.2 marks

2. Managing the CPU: Processes and Scheduling

When you run a program, the operating system loads it into memory and it becomes a 'process'. A process is a program in execution. Modern operating systems are 'multitasking', meaning they can handle many processes at once (e.g., a web browser, a word processor, and a music player). Since there is usually only one CPU, it can only execute one instruction at a time. The OS creates the illusion of multitasking by rapidly switching the CPU's attention between different processes. This switching is managed by a part of the OS called the scheduler. The scheduler's job is to decide which process in the 'Ready' queue should be run next. A process can be in several states: 'New' (being created), 'Ready' (waiting for the CPU), 'Running' (currently being executed by the CPU), 'Blocked' (waiting for an event, like user input or a file to load), and 'Terminated' (finished execution). An 'interrupt' is a signal to the CPU (from hardware or software) that requires immediate attention, causing the current process to be paused so the interrupt can be handled.

Key term

Process: A program that has been loaded into memory and has begun execution.

Examiner insight

High marks are awarded for clearly explaining the transitions between process states, for example, explaining that a process moves from 'Running' to 'Blocked' when it makes an I/O request, and from 'Blocked' to 'Ready' when the I/O is complete.

Common pitfall

Confusing a 'program' (a static set of instructions on a disk) with a 'process' (a dynamic instance of a program running in memory with its own data and state).

Worked example 16 marks

A process can exist in several states. Identify three process states and explain a reason for a process to be in each state. [6]

  1. 1
    1. State: Running. A process is in the running state when it is currently being executed by the CPU. There can only be one running process per CPU core at any given moment.
  2. 2
    1. State: Ready. A process is in the ready state when it is loaded in main memory and is waiting for its turn to be allocated to the CPU by the scheduler. It is prepared to execute but another process is currently running.
  3. 3
    1. State: Blocked (or Waiting). A process enters the blocked state when it cannot continue without an external event. For example, it might be waiting for data to be read from a hard disk, or waiting for user input from the keyboard.

Worked example 23 marks

Explain the role of interrupts in a modern computer system. [3]

  1. 1
    1. An interrupt is a signal sent to the CPU that indicates an event needing immediate attention.
  2. 2
    1. When an interrupt occurs, the CPU suspends its current process, saving its state.
  3. 3
    1. The CPU then executes a special routine called an Interrupt Service Routine (ISR) to handle the event, before resuming the original process. This allows the OS to manage I/O devices and handle errors efficiently without constantly polling them.

Recap

  • A process is an active program that is currently executing.
  • Multitasking is achieved by the OS rapidly switching the CPU between processes.
  • The scheduler is the OS component that decides which process to run next.
  • The main process states are New, Ready, Running, Blocked, and Terminated.
  • A process moves from Running to Blocked when it needs to wait for an I/O operation.
  • Interrupts are signals that pause the current process to allow the OS to handle urgent events.

Quick check

  1. What is the difference between a program and a process?2 marks
  2. Which OS component decides which process to run next?1 mark

3. Memory Management with Paging and Virtual Memory

Memory management is crucial for an OS. It must allocate memory fairly and protect processes from each other. 'Paging' is a common technique where memory is divided into fixed-size blocks. A program's logical address space is split into 'pages', and the physical RAM is split into 'frames' of the same size. A 'page table' is used to map the logical pages of a program to physical frames in RAM. This means a program's memory can be scattered non-contiguously throughout RAM, which makes allocation more flexible. 'Virtual memory' is a clever extension of paging. It uses a portion of the hard disk or SSD as if it were extra RAM. When RAM is full, the OS can move a 'page' of data that is not currently in use from RAM to the secondary storage (this is called 'swapping out'). When that page is needed again, it is swapped back into RAM, possibly replacing another page. This allows you to run larger programs or more programs than your physical RAM would normally allow. However, if the system spends too much time swapping pages back and forth, it can lead to a condition called 'disk thrashing', where the computer slows to a crawl because it is constantly accessing the slow hard disk instead of executing programs.

Key term

Virtual Memory: A memory management technique that uses secondary storage to extend the apparent size of physical memory (RAM).

Examiner insight

Students should be able to explain how paging enables virtual memory. For disk thrashing, clearly link the problem to excessive page swapping due to insufficient physical memory for the active processes.

Common pitfall

Believing that virtual memory makes the computer run faster. Accessing data from virtual memory (on a disk) is thousands of times slower than accessing it from RAM. Its benefit is capacity, not speed.

Fun fact

The concept of virtual memory was first developed in the late 1950s at the University of Manchester for the Atlas Computer, which was one of the world's first supercomputers and cost around £2.5 million in 1962.

Worked example 14 marks

Explain what is meant by 'paging' in memory management and the role of the page table. [4]

  1. 1
    1. Paging is a memory management scheme where physical memory is divided into fixed-size blocks called frames.
  2. 2
    1. A program's logical memory is also divided into blocks of the same size, called pages.
  3. 3
    1. When a program is executed, its pages are loaded into any available frames in physical memory. These frames do not need to be contiguous.
  4. 4
    1. The operating system maintains a page table for each process, which maps the logical page numbers to their corresponding physical frame numbers in RAM. The CPU uses this table to translate logical addresses into physical addresses.

Worked example 24 marks

Describe two advantages of using virtual memory and explain the problem of 'disk thrashing'. [4]

  1. 1
    1. Advantage 1: Larger programs can be run. Programs can be larger than the physical RAM available because only the necessary parts need to be in RAM at any one time.
  2. 2
    1. Advantage 2: Increased degree of multiprogramming. More processes can be kept in memory simultaneously, which can lead to better CPU utilisation and system throughput.
  3. 3
    1. Disk Thrashing: This is a problem where the system spends an excessive amount of time swapping pages between RAM and secondary storage. It happens when there is not enough physical RAM to hold the working set of pages for the current processes. The CPU spends more time waiting for pages to be loaded than executing code, causing severe performance degradation.

Recap

  • Paging divides logical and physical memory into fixed-size blocks (pages and frames).
  • A page table maps a program's logical pages to physical frames in RAM.
  • Virtual memory uses secondary storage to simulate a larger amount of RAM.
  • Swapping is the process of moving pages between RAM and the hard disk.
  • Virtual memory allows larger programs and more multitasking.
  • Disk thrashing occurs when excessive swapping slows the system down dramatically.

Quick check

  1. What is the purpose of a page table?2 marks
  2. What is disk thrashing and what is its main cause?2 marks

4. System Utilities and Program Libraries

Beyond the core OS, system software also includes 'utility programs'. These are small applications designed to perform specific maintenance tasks to help manage, analyse, and optimise the computer system. Common examples include: 'Disk Defragmenter', which reorganises files on a hard disk to be stored in contiguous blocks, speeding up access; 'Backup Utility', which creates copies of data to protect against loss; 'File Compression', which reduces the size of files to save disk space or speed up transfer; and 'Disk Cleaner', which finds and removes unnecessary temporary files. Separately, in software development, programmers rely heavily on 'program libraries'. A library is a collection of pre-written, pre-compiled, and tested code (like functions or classes) that a developer can use in their own programs. Using libraries saves significant time and effort, as the programmer doesn't have to 'reinvent the wheel'. It also improves reliability, as library code is often written by experts and thoroughly tested. Libraries can be linked 'statically' (the library code is copied into the final executable) or 'dynamically' (the code is kept in a separate file, like a .dll in Windows, and loaded only when needed).

Key term

Utility Program: System software designed to perform a specific maintenance or analysis task on the computer system.

Examiner insight

For utility programs, it's not enough to just name one; you must also explain what it does and why it's needed. For example, 'A disk defragmenter reorganises fragmented files into contiguous blocks to improve disk access speed'.

Worked example 14 marks

Identify two utility programs that might be used to manage a hard disk and explain what each one does. [4]

  1. 1
    1. Utility: Disk Defragmenter. Explanation: Over time, as files are saved, modified, and deleted, parts of a single file can become scattered across different physical locations on the disk (fragmentation). A defragmenter reorganises these parts into a single, contiguous block. This reduces the time it takes for the read/write heads to access the file, improving performance.
  2. 2
    1. Utility: Disk Formatter / Disk Checker. Explanation: A formatter prepares a disk for use by creating a file system structure. A disk checker (like CHKDSK) scans the disk for errors, such as bad sectors or file system corruption, and can attempt to repair them to prevent data loss.

Worked example 24 marks

Explain two benefits to a programmer of using library routines when developing new software. [4]

  1. 1
    1. Saves Development Time: Programmers can use pre-written code for common tasks (e.g., mathematical calculations, string manipulation) instead of writing it from scratch. This significantly speeds up the development process.
  2. 2
    1. Improves Reliability and Quality: Library code is typically written by experts and has been extensively tested and debugged across many applications. Using this robust code reduces the chance of errors in the programmer's own application.

Recap

  • Utility programs perform maintenance and optimisation tasks for the computer system.
  • Examples of utilities include disk defragmenter, backup software, and file compression.
  • Program libraries are collections of pre-written, reusable code for developers.
  • Using libraries saves time, reduces errors, and allows programmers to focus on unique application logic.
  • Dynamic Link Libraries (DLLs) are shared libraries that can be used by multiple programs at once.
  • A disk defragmenter improves disk access speed by making files contiguous.

Quick check

  1. What is the purpose of a disk defragmenter?1 mark
  2. State one advantage of using a Dynamic Link Library (DLL) over static linking.1 mark

5. Translators: Compilers, Interpreters, and Assemblers

Computers understand only one language: machine code, which consists of binary 1s and 0s. Humans, however, write programs in high-level languages (like Python or Java) or low-level assembly language, which are easier to understand. 'Language translators' are system programs that bridge this gap. There are three main types:

  1. Compiler: A compiler takes the entire source code of a program and translates it into machine code all at once. This process, called compilation, produces a standalone executable file (e.g., an .exe file on Windows). This executable can then be run independently without the original source code or the compiler. The translated code generally runs very fast.
  2. Interpreter: An interpreter works differently. It reads the source code one line or statement at a time, translates that line into machine code, and then immediately executes it. It then moves to the next line. No separate executable file is created. This process is repeated every time the program is run.
  3. Assembler: An assembler is a translator for assembly language. Assembly language is a very low-level language that has a strong one-to-one correspondence with the computer's machine code instructions. The assembler performs a relatively straightforward conversion of these mnemonics (like ADD, MOV) into their binary equivalents.

Key term

Compiler: A program that translates source code from a high-level programming language into machine code all at once, creating a separate executable file.

Examiner insight

Questions often ask for a comparison between compilers and interpreters. Key points to mention are: translation method (all at once vs. line-by-line), speed of execution of the final code, how errors are reported, and the output produced (executable vs. none).

Common pitfall

Confusing the roles of compilers and interpreters. A key difference to remember is that a compiler produces a separate executable file before runtime, while an interpreter translates during runtime.

Worked example 13 marks

State three differences between how an interpreter works and how a compiler works. [3]

  1. 1
    1. Translation: A compiler translates the entire source code into an executable file before the program is run. An interpreter translates and executes the code line-by-line during runtime.
  2. 2
    1. Output: A compiler produces a standalone executable file of machine code. An interpreter does not produce a separate executable file.
  3. 3
    1. Error Reporting: A compiler reports all syntax errors at the end of the compilation process. An interpreter stops execution and reports an error as soon as it encounters one.

Worked example 24 marks

Discuss one advantage and one disadvantage of using an interpreter compared to a compiler during program development. [4]

  1. 1
    1. Advantage of Interpreter: Debugging is often easier. Since the interpreter stops at the exact line where an error occurs, the programmer can immediately see the context of the error and the state of the variables, making it faster to find and fix bugs.
  2. 2
    1. Disadvantage of Interpreter: Execution speed is slower. The program has to be translated every time it is run, and the line-by-line translation process adds overhead. Compiled code, being already in machine code form, runs much faster.

Recap

  • Language translators convert human-readable source code into machine code.
  • A compiler translates the entire program at once, creating a fast, standalone executable.
  • An interpreter translates and executes the program one line at a time, and is generally slower.
  • An assembler translates low-level assembly language into machine code.
  • Interpreters are often preferred during development for easier debugging.
  • Compilers are preferred for distributing finished software due to speed and not needing to share source code.

Quick check

  1. Which translator produces a standalone executable file?1 mark
  2. Which translator is generally better for debugging and why?2 marks

6. Inside a Compiler: The Stages of Compilation

Compilation isn't a single step; it's a multi-stage process that transforms source code into machine code. The main stages are:

  1. Lexical Analysis: The compiler scans the source code as a string of characters. It removes comments and whitespace and groups characters into a sequence of 'tokens'. A token is the smallest meaningful unit, like a keyword (`if`), an identifier (`myVariable`), an operator (`+`), or a number (`10`). Information about identifiers is stored in a 'symbol table'.
  2. Syntax Analysis (Parsing): The stream of tokens is checked to see if it follows the grammar rules of the programming language. The parser builds a data structure, often an 'Abstract Syntax Tree' (AST), which represents the grammatical structure of the code. If the code violates a grammar rule (e.g., a missing semicolon), a syntax error is reported.
  3. Semantic Analysis: This stage checks the AST for meaning. While the code might be grammatically correct, it might not make logical sense. This stage detects errors like using an undeclared variable, or trying to add a string to an integer (a type mismatch).
  4. Intermediate Code Generation: The compiler generates a low-level, machine-independent representation of the program. This intermediate code is easier to optimise and can be more easily adapted to generate final code for different CPU architectures.
  5. Code Optimisation: This optional but important stage analyses the intermediate code and transforms it to make the final program run faster or use less memory. It might remove redundant code or rearrange instructions.
  6. Code Generation: The final stage. The optimised intermediate code is translated into the specific machine code for the target computer's architecture. This is the output executable file or object code.

Key term

Syntax Analysis: The stage of compilation where the sequence of tokens is checked against the grammatical rules of the programming language to build a parse tree.

Examiner insight

Students should be able to name and describe the purpose of at least the first three stages of compilation: lexical analysis, syntax analysis, and semantic analysis. Mentioning the role of the symbol table or parse tree shows deeper understanding.

Common pitfall

Mixing up syntax and semantic errors. A syntax error is a grammar violation (e.g., `whlie x < 5`), while a semantic error is grammatically correct but logically meaningless (e.g., `let x = 'hello' + 5;`).

Worked example 14 marks

Describe the purpose of lexical analysis and syntax analysis during the compilation of a program. [4]

  1. 1
    1. Lexical Analysis: This is the first stage. Its purpose is to read the source code and convert the stream of characters into a stream of meaningful tokens. It also removes unnecessary elements like comments and whitespace and builds a symbol table to keep track of variables and functions.
  2. 2
    1. Syntax Analysis: This is the second stage, also known as parsing. Its purpose is to take the stream of tokens from the lexical analyser and check if they conform to the grammar rules of the language. It does this by attempting to build a parse tree or abstract syntax tree from the tokens. If the structure is invalid, it reports a syntax error.

Worked example 22 marks

A compiler detects an error when it finds the statement `x = 'hello' + 5;` in a language where this is not allowed. In which stage of compilation would this error be detected, and what type of error is it? [2]

  1. 1
    1. Stage: Semantic Analysis. The statement is grammatically correct (syntax is valid: variable = value + value), so it would pass syntax analysis.
  2. 2
    1. Error Type: It is a semantic error (specifically, a type mismatch error), as it is meaningless to add a string to an integer in this context. The semantic analyser checks for such logical and type-related inconsistencies.

Recap

  • Compilation is a multi-stage process converting source code to machine code.
  • Lexical analysis creates tokens from source code and builds a symbol table.
  • Syntax analysis checks the tokens against language grammar rules, creating a parse tree.
  • Semantic analysis checks the parse tree for logical meaning and type consistency.
  • Code optimisation improves the efficiency of the generated code.
  • Code generation produces the final machine code for a specific processor.

Quick check

  1. Which stage of compilation removes comments and whitespace?1 mark
  2. In which stage would a 'type mismatch' error be detected?1 mark

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. Identify four main functions of an operating system.4 marks
  2. Explain the difference between a command-line interface (CLI) and a graphical user interface (GUI), giving one advantage of each.4 marks
  3. A program is being executed on a computer with a multitasking operating system. Explain what a 'process' is and describe the 'Ready' and 'Blocked' process states.5 marks
  4. Describe how paging and a page table are used by an operating system to manage non-contiguous memory.5 marks
  5. Explain two benefits and one potential drawback of using virtual memory.3 marks
  6. A programmer is using a library of pre-written functions to build a new application. State two reasons why this is a good practice.2 marks
  7. Compare the use of a compiler with the use of an interpreter. Your answer should refer to the translation process, speed of execution of the resulting code, and how errors are handled.6 marks
  8. Describe the first three stages of compilation: lexical analysis, syntax analysis, and semantic analysis.6 marks
  9. Some languages, like Java, use a hybrid approach involving both compilation and interpretation. Describe how this works and state one advantage of this method.3 marks
  10. Explain the purpose of two different system utility programs. For each, describe a situation where it would be used.4 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters