AS & A Level Computer Science · Area 1 · AS Level content

Operating systems and language translators

You need to be able to say what each management task of an operating system actually does, not just name it, and to choose between a compiler and an interpreter for a stated situation with a reason. Most marks here are lost by describing the operating system as the software you work in, by naming a utility program without saying what problem it solves, and by writing that a compiler is better than an interpreter without saying better at what.

Not started

Syllabus coverage

  • Why a computer system requires an operating system (OS)
  • Key management tasks: memory management and process management
  • Key management tasks: file management, security management and hardware management (input/output/peripherals)
  • The need for typical utility software provided with an OS: disk formatter, virus checker
  • Utility software continued: defragmentation software, disk contents analysis/disk repair software, file compression, back-up software
  • Program libraries: software under development is often constructed using existing code from program libraries
  • The benefits to the developer of software constructed using library files, including Dynamic Link Library (DLL) files
  • The need for assembler software for the translation of an assembly language program
  • The need for a compiler for the translation of a high-level language program
  • The need for an interpreter for translation and execution of a high-level language program
  • Benefits and drawbacks of using either a compiler or an interpreter, and justification of the use of each
  • High-level language programs may be partially compiled and partially interpreted, such as Java (console mode)
  • Features of a typical IDE for coding, including context-sensitive prompts
  • IDE features for initial error detection (dynamic syntax checks), for presentation (prettyprint, expand and collapse code blocks) and for debugging (single stepping, breakpoints, variables, expressions, report window)

Part of the AS & A Level Computer Science syllabus 9618.

Paging: virtual pages to framesVirtual memory is cut into fixed-size pages and physical memory into frames.Each page is loaded into any free frame; the page table records where.Virtual memoryPhysical memoryPage 0Frame 0Page 1Frame 1Page 2Frame 2Page 3Frame 3Page tablepage -> frame01102332
Paging: pages of a process are mapped through the page table into any free frames of physical memory.

Why a computer system needs an operating system

An operating system (OS) is system software that manages the hardware and the software of a computer system and provides the services that every program needs. Without one, each program would have to carry its own code for reading a disk, sending output to a screen, and deciding when it is allowed to use the processor.

The OS exists because the resources it shares out are limited. The processor can execute one fetch-execute cycle at a time and main memory is finite, so if two programs helped themselves to memory they would overwrite each other's data and bring the machine down. The OS allocates processor time and memory to each program, keeps the programs apart, and takes the resources back when a program ends.

It also hides the complexity of the hardware. A program that saves a file does not need to know whether the file is on a hard disk, a USB flash drive or a network server; it asks the OS, which knows the details of that device and its driver. This is why the same application can run on machines built from completely different components.

Finally, the OS provides the environment the user works in and the platform that application software is written against. It offers a user interface (a graphical interface of windows, icons and pointers, or a command line), it enforces security so that one user cannot open another's files, it reports and handles errors instead of letting a fault stop the machine, and it loads and runs the programs the user asks for.

  • Manages resources: shares the processor, memory, storage and peripherals between the programs that want them, so that they do not conflict.
  • Hides the hardware: application software calls the OS rather than the hardware, so it does not depend on the make and model of the components.
  • Provides the user interface: a graphical interface or a command line, which is how the user actually controls the machine.
  • Provides a platform: every application depends on the services of the OS, which is why software is written for Windows, macOS or Linux rather than for a processor.
  • Manages data and security: files, folders, access rights and user accounts are all controlled by the OS.
  • Handles errors: reports a failed read, an unavailable printer or a program that has crashed, and keeps the rest of the system running.
A computer can run with no application software installed, but not with no operating system. Saying that it lets you use a word processor is not a reason for needing an OS: the word processor is application software that runs on the platform the OS provides.

Memory management and process management

Memory management is the OS keeping track of main memory: which locations are free, which are in use, and which program is using them. When a program is loaded the OS allocates it a block large enough for its code and its data, and when the program ends it marks that memory free again so that the next program can have it.

The OS also has to protect memory. Each process is confined to the area it has been given, so a fault in one program cannot overwrite the code or data of another program, or of the OS itself. If that protection fails, one crashed program takes the whole system down with it.

Main memory is limited, and users expect to have several programs open at once. When there is not enough free memory the OS has to make room, for example by moving data that is not being used out to backing store and bringing it back when it is needed, and it has to decide how much memory each program may have so that one large program cannot starve the others.

A process is a program that is being executed. Process management is the OS deciding which process uses the processor, and for how long. It provides multitasking: each process gets a short turn on the processor in rotation, and the switching is fast enough that everything appears to be running at the same time.

It also gives some processes priority over others, so that the process reading input from the keyboard is not kept waiting behind a long calculation; it lets a process that is waiting for a device give up the processor instead of wasting it; and it closes a process that has finished or crashed and releases its memory and files.

  • Memory management: records which memory is free, allocates a block to each program when it is loaded, frees it when the program ends, and stops one program writing into another's memory.
  • Process management: decides which process runs next and for how long, switches between them to give multitasking, applies priorities, and terminates processes that have finished or crashed.
  • A process is a program in execution - the program file on disk becomes a process when it is loaded into memory and being run.
  • Process management is judged by what it achieves: several programs making progress, the processor never left idle waiting for a slow device, and no single program taking over the machine.
Keep process management at the level of what the OS achieves. The detailed scheduling routines and the process states running, ready and blocked belong to the A Level treatment of operating systems, not to this section.

File management and hardware management

File management is how the OS stores, finds and protects data on secondary storage. It maintains the directory structure of folders and files, records where on the disk each file is stored, and provides the operations the user needs: create, open, save, copy, rename, move and delete.

It also keeps each file's metadata - the name, size, type, date created and date last modified - and the access rights that say who may read, write or delete it. On a shared machine those rights are what stop another user opening your work, and the OS checks them every time a file is opened.

Because secondary storage is finite, the OS tracks which blocks are free and which are in use and allocates space as a file grows. A file does not have to be stored in one piece: the OS records the list of blocks that belong to it, which is why a badly fragmented disk still works, just more slowly.

Hardware management means controlling the input, output and peripheral devices attached to the machine. Each device needs a device driver: software, supplied with the device, that tells the OS how to send it commands and how to read data back. The OS loads the driver, and a program can then print or read a sensor without knowing anything about the electronics.

The OS also has to cope with devices that are far slower than the processor. It uses a buffer, an area of memory that holds data while it is being transferred, so the processor can hand over a block of data and continue with something else instead of waiting. For printers it goes further and uses spooling: the documents are queued on disk and fed to the printer one at a time, which lets several users share one printer and carry on working the moment they press print.

TermWhat it meansWhy the OS needs it
Directory structureThe tree of folders and files, with a record of where each file's blocks are storedSo that a file can be found by name without the user knowing anything about the disk
MetadataThe information stored about a file: name, size, type, dates, access rightsSo that files can be listed, sorted, associated with an application and protected
Device driverSoftware that translates the OS's commands into signals a particular device understandsSo that one OS can control thousands of different printers, graphics cards and sensors
BufferAn area of memory holding data during a transfer between devices of different speedsSo that the processor is not idle while a slow device catches up
SpoolingQueueing jobs for a device, usually a printer, on disk and sending them one at a timeSo that several users can share one printer and each can carry on working immediately
Spooling and buffering are not the same thing. A buffer holds data for a moment inside memory to cover a speed difference; a spool is a queue of whole jobs held on disk so that a shared device can work through them in turn.

Security management

Security management is the OS controlling who may use the computer and what they may do once they are in. It starts with user accounts: the OS holds a list of users, checks a username and password at logon, and attaches an identity to everything that user does afterwards.

Each account has a level of privilege. An administrator can install software, change settings and reach every file; a standard user can run programs and save work in their own area but cannot alter the system. File and folder permissions add a finer level: a file can be set so that one user may read it but not change it, another may change it, and a third cannot open it at all.

The OS also keeps processes apart, so a program run by one user cannot read the memory of another, and it logs activity - who logged on, when, and which files were opened - so that a suspicious event can be traced afterwards. It can enforce password rules, lock an unattended machine after a period of inactivity, and block programs from running from removable media.

What the OS cannot do is protect data from a user who has been given the right to see it, or stop someone with physical access to the machine removing the disk. That is why security management is backed up by encryption and by physical security, which are covered in the security section of the syllabus.

  • User accounts and authentication: each user has a username and password, and the OS checks them before allowing access to the system.
  • Access rights and permissions: each file, folder and device can be set to allow read, write or execute for particular users or groups.
  • Privilege levels: an administrator account can change the system; a standard account cannot.
  • Logging: records of logons and file access allow an event to be investigated after it has happened.
  • Isolation: memory protection and process management stop one user's program reaching another user's data.
  • Limits: the OS cannot protect data from someone who is entitled to see it, and it cannot protect a disk that has been physically removed.
In a question about security management, the marks are for accounts, passwords, permissions and logs. Antivirus software and a firewall are separate security measures, and naming a utility program as a management task does not score.

The utility programs supplied with an operating system

Utility software is a set of small programs, usually supplied with the OS, that keep the computer healthy. Each one does a single housekeeping job and is started by the user or by a schedule. They are system software because they maintain the machine rather than do a task for the user, but the computer would still run without them.

A disk formatter prepares a storage medium so that it can be used: it sets up the file system and the structures the OS needs in order to store files, marks any bad sectors so that they are not used, and removes everything already on the disk. A virus checker scans files, memory and downloads for known malware, comparing what it finds against a database of signatures, and then quarantines, repairs or deletes anything infected; its signature list has to be updated regularly or it stops recognising new threats.

Defragmentation software deals with a magnetic hard disk whose files have become scattered. As files are created, resized and deleted, the blocks that belong to one file end up in different places, so the read/write head has to move to several locations to read it. Defragmentation rearranges the blocks so that each file occupies contiguous blocks and the free space is collected together, which means fewer head movements and faster reading. Disk contents analysis shows how much space each file and folder is using so that large or unneeded files can be found and removed, and disk repair checks the file system for errors, fixes them where it can, marks bad sectors, and may recover data from damaged files.

File compression reduces a file's size so that it takes less storage space and transfers faster over a network; a lossless method keeps all the original data, which is essential for a program or a document, while a lossy method discards detail and is only acceptable for images, sound and video. Back-up software makes copies of files to a separate medium, such as an external drive or cloud storage, so that work can be restored after accidental deletion, corruption, theft or a hardware failure; it can be scheduled to run automatically, and a full backup copies everything while an incremental backup copies only what has changed since the last one.

UtilityWhat it doesThe problem it solves
Disk formatterPrepares a disk for use: sets up the file system and the structures needed to store files, marks bad sectors, removes all existing dataA new disk cannot hold files until it has been prepared in the format the OS expects
Virus checkerScans files, memory and downloads for known malware by comparing against a signature database, then quarantines, repairs or deletesMalware that would corrupt files, steal data or spread to other machines
Defragmentation softwareRearranges the blocks of each file so that they are stored next to each other and free space is collected togetherFiles scattered across a magnetic disk take longer to read because the read/write head has to move further
Disk contents analysis / disk repairAnalysis reports how much space each file and folder uses; repair checks the file system for errors, fixes them, marks bad sectors and can recover dataA disk that is full, or whose file system has been damaged by a crash or a power failure
File compressionReduces file size by storing the data more efficiently; lossless keeps all the data, lossy discards detailNot enough storage space, or a file too large to send quickly over a network
Back-up softwareCopies files to another medium on a schedule, as a full or an incremental backup, so that they can be restoredDeletion by mistake, corruption, theft, ransomware or a failed drive
Defragmentation is the one utility whose value depends on the hardware. A magnetic hard disk has a read/write head that must physically move to each block, so making files contiguous speeds it up. A solid-state drive has no moving parts, gains nothing, and is worn out faster by the extra writes, so it is never defragmented.

Program libraries and DLL files

A program library is a collection of pre-written, tested routines that a programmer can call from their own code instead of writing the code again. A library might provide routines for sorting, for handling text, for drawing a window or for reading a file; the programmer links the library into the program and calls a routine by name, passing it the data it needs.

The benefit to the developer is mostly time and risk. The routines have already been written and tested, often by specialists, so the developer does not spend weeks reinventing them and inherits fewer bugs. The library is usually efficient and deals with awkward cases such as unusual input, the code in the program itself is shorter and easier to read, and if the library is later corrected, every program that uses it gains the fix.

There are two ways to use a library. With a static library, the routine's code is copied into the finished program when it is linked, so the program carries its own copy and will run on its own. With a dynamic link library (DLL), the code stays in a separate file: the program records that it needs the DLL, and the OS loads the DLL into memory when the program runs and lets the program call into it.

The advantages of a DLL follow from that. The code is not copied into the executable, so the executable is smaller and takes less disk space; one copy of the DLL can be loaded into memory and shared by several programs running at once, so less memory is used overall; and the DLL can be replaced with a corrected or improved version without recompiling or redistributing the programs that use it. The drawback is dependence: if the DLL is missing, or is a different version from the one the program was built against, the program will not start, and a faulty DLL can affect every program that loads it.

FeatureStatic libraryDynamic link library (DLL)
Where the code isCopied into the executable when the program is linkedKept in a separate file and loaded when the program runs
Size of the executableLarger, because it carries the library codeSmaller, because only a reference to the DLL is stored
Use of memoryEach program has its own copy in memoryOne copy can be shared by several programs at the same time
UpdatingThe program must be relinked and recompiledThe DLL can be replaced without changing the programs that use it
RiskThe program is self-contained and always has what it needsThe program will not run if the DLL is missing or the wrong version
The DLL mark is for the mechanism and its consequence: the code is not copied into the executable but loaded at run time, so the executable is smaller and one copy in memory can be shared. Writing only that a DLL is a library scores nothing.

The three translators: assembler, compiler and interpreter

A processor can execute only machine code: binary opcodes with binary operands. Anything a programmer writes has to be turned into machine code before it can run, and the software that does the turning is a translator.

An assembler translates an assembly language program into machine code. Assembly language uses mnemonics such as LDM, ADD and STO in place of binary opcodes, and labels in place of numeric addresses. The assembler converts each mnemonic into its opcode, works out the address that each label stands for and substitutes it, and produces machine code. Translation is close to one instruction for one instruction, so assembly language is specific to a processor family: a program written for one will not run on another.

A compiler translates a whole high-level language program into machine code, producing an executable file, before the program is run. It analyses the entire program, reports every syntax error it finds at the end of compilation, and produces no executable until the errors are corrected. Once compiled, the program runs on its own, without the compiler and without the source code, and it runs quickly because the translation has already been done.

An interpreter translates and executes a high-level language program one statement at a time, and does not produce a saved machine code file. It stops as soon as it reaches an error, reporting the statement where the error occurs, and it translates the program again every time it is run. That makes it slower at run time than a compiled program, but it gives immediate feedback and no compile stage, which is why it is used while a program is being written and tested.

TranslatorInputOutputWhen the translation happens
AssemblerAn assembly language program of mnemonics and labelsMachine code (an object file that is then linked)Before the program is run, once
CompilerA whole high-level language programMachine code in an executable fileBefore the program is run, once, and the executable is kept
InterpreterA high-level language program, one statement at a timeNo saved translated file; the statements are executed as they are translatedWhile the program is running, and again on every run
Assembly language is not machine code, but it is one step away from it: mnemonics stand for single opcodes and labels stand for addresses. That one-to-one relationship is why an assembler is a simpler translator than a compiler, and why assembly language is tied to one processor family.

Choosing between a compiler and an interpreter, and the Java compromise

A compiler's advantages all come from translating once, in advance. The finished program runs faster because no translation happens while it runs; it can be supplied without the source code, which protects the developer's work; every error is reported together after the whole program has been analysed, so they can all be fixed in one session; and the compiler can optimise the code as it translates. Its drawbacks are that nothing can be run until the whole program compiles, that every change means another compile, and that the executable is specific to one processor and operating system, so a version is needed for each platform.

An interpreter's advantages come from working line by line. There is no compile stage, so a change can be tried immediately; it stops at the exact statement where the error is and reports it there, which is far more useful while a program is being developed or learned; code can be run and tested a fragment at a time; and the same source file can run on any machine that has an interpreter. Its drawbacks are that it is slower at run time because the translation is repeated, that the interpreter must be installed on the user's machine, and that the source code is visible, so it cannot be protected or hidden.

Java is the standard example of a program that is partly compiled and partly interpreted. The Java compiler does not produce machine code for a particular processor; it produces bytecode, an intermediate code for a virtual machine. When the program is run, the Java Virtual Machine on that computer either interprets the bytecode or compiles the parts of it that are used most into machine code as it goes.

The result is a compromise that keeps some of both. Errors are caught by the compiler before anything runs, the source code is not distributed, and the same bytecode runs on any computer that has a JVM, so the program is portable without being recompiled for each platform. The cost is that a JVM must be installed and that execution is usually slower than a program compiled directly to machine code.

CriterionCompilerInterpreter
Unit of translationThe whole program at onceOne statement at a time
ProductAn executable file of machine codeNo saved translated file
Speed at run timeFaster, because translation has already happenedSlower, because the translation is repeated on every run
Error reportingAll syntax errors reported after the whole program is analysed; nothing runs until they are fixedStops at the first error and reports the statement it occurs in
DevelopmentSlow to test changes, because the program must be recompiled each timeImmediate: change the code and run it again
DistributionRuns without the translator and without the source, so the code is protectedNeeds the interpreter installed and exposes the source code
PortabilityThe executable is tied to one processor and operating systemThe same source runs anywhere an interpreter exists
Justify means choose, then give the reason that follows from the situation in the question. Selling software to thousands of users points to a compiler, because the executable runs without a translator and the source is not given away. Writing and testing a program points to an interpreter, because it stops at the line with the error and needs no compile step.

The integrated development environment

An integrated development environment (IDE) is a single application that brings together the tools a programmer needs: an editor for writing code, the translator for running it, a debugger, and usually a project manager for the files that make up the program. Working in one window means the programmer is not switching between separate programs and losing track of which file is which.

For coding, the IDE offers context-sensitive prompts. As the programmer types, the IDE offers only what is valid at that point: after typing the name of an object and a dot it lists that object's methods and properties; inside a procedure call it shows the parameters the routine expects. This reduces typing and prevents spelling mistakes in names. For initial error detection it applies dynamic syntax checks, checking the code as it is typed rather than only when it is compiled, so a missing bracket or a misspelt keyword is flagged on the line where it occurs before the program is ever run.

For presentation, prettyprint reformats the code automatically, indenting and spacing it so that loops, conditions and blocks can be seen at a glance, and expand and collapse code blocks lets the programmer fold away whole routines so that a long program can be navigated and its overall structure seen.

For debugging, single stepping executes one statement at a time so that the programmer can follow exactly what each line does, and a breakpoint pauses the program at a chosen line so that the state can be inspected at that moment without stepping through everything before it. At either point the variables, expressions and report window show the current value of each variable and of any expression the programmer has chosen to watch, which is how a wrong value is traced back to the statement that produced it.

IDE featureWhat it doesWhat it helps the programmer do
Context-sensitive promptsSuggests only the keywords, names, methods or parameters that are valid at the cursor positionWrite correct code faster, with fewer typing and spelling errors
Dynamic syntax checksChecks the syntax as the code is typed and flags errors immediatelyFind and fix a mistake before compiling or running the program
PrettyprintReformats the code with consistent indentation and spacingRead the structure of the code and spot a block that is in the wrong place
Expand and collapse code blocksFolds away sections or whole routines, and opens them againNavigate a long program and see its overall structure
Single steppingExecutes one statement at a time on demandFollow the effect of each statement in order
BreakpointsPauses execution at a chosen lineInspect the state at a particular point without stepping through the code before it
Variables, expressions and report windowDisplays the current value of chosen variables and expressionsSee where a value became wrong and which statement changed it
The mark is for what the feature does for the programmer, not for the name. Breakpoints help with debugging earns nothing; a breakpoint pauses the program at a chosen line so the values in memory can be inspected at that point earns the mark.

Key terms you must be able to define

Operating system (OS)
System software that manages the hardware and software of a computer system. It allocates processor time, memory, storage and peripherals between programs, hides the complexity of the hardware, provides a user interface, enforces security and provides the platform on which application software runs.
Utility software
Small housekeeping programs, usually supplied with the operating system, that each perform one maintenance task - such as formatting a disk, checking for viruses, defragmenting a disk, analysing or repairing disk contents, compressing files or backing up files.
Process
A program that is being executed: the program file loaded into memory with the resources the operating system has allocated to it. The operating system decides which process uses the processor and for how long.
Device driver
Software, supplied with a piece of hardware, that tells the operating system how to send commands to that device and how to read data back from it, so that programs can use the device without knowing how it works.
Buffer
An area of main memory that holds data temporarily while it is being transferred between devices that work at different speeds, so that the processor can continue with another task instead of waiting for the slower device.
Spooling
Holding jobs for a device, usually a printer, in a queue on disk and sending them to the device one at a time. It allows several users to share one device and lets each of them carry on working as soon as the job is queued.
Defragmentation
Reorganising the blocks of a magnetic hard disk so that the parts of each file are stored next to one another and the free space is collected together, which reduces the movement of the read/write head and so speeds up reading. It brings no benefit on a solid-state drive.
Program library
A collection of pre-written and tested routines that a programmer can call from their own program instead of writing the code again, which saves development time and reduces the number of errors.
Dynamic link library (DLL)
A library file whose code is kept separately from the program and loaded into memory by the operating system when the program runs. The executable is smaller, one copy can be shared by several programs, and the DLL can be updated without recompiling the programs that use it.
Assembler
A translator that converts an assembly language program into machine code, replacing each mnemonic with its opcode and each label with the address it represents.
Compiler
A translator that converts a whole high-level language program into machine code before it is run, producing an executable file. It reports all syntax errors at the end of compilation and produces nothing until they are corrected.
Interpreter
A translator that translates and executes a high-level language program one statement at a time while it runs, without producing a saved machine code file. It stops at the first error and reports the statement it occurs in.
Bytecode
An intermediate, machine-independent code produced by compiling a language such as Java. It is not the machine code of any particular processor, so it is executed by a virtual machine on the target computer.
Integrated development environment (IDE)
A single application that combines an editor, a translator, a debugger and project management tools, with features such as context-sensitive prompts, dynamic syntax checks, prettyprint, expandable code blocks, single stepping, breakpoints and a variables window.

Applied to real systems

9618 sets its questions inside systems you already use - a phone, a school network, a supermarket till, a website, a bank. These show how to apply the theory to a context you have not seen before, then you write your own.

An operating system at work: Android on a phone

Android is an operating system built on a Linux kernel, and every management task in this topic can be seen in it. It allocates memory to the app in the foreground and closes background apps when memory runs low, which is memory management; it keeps each app in its own process and stops one app reading another's data, which is process management and security management together. It stores the user's photographs and downloads in a file system with per-app permissions, and it loads drivers for the touchscreen, camera, speaker and radio so that an app can play a sound without knowing which chip produces it. It also ships utility software in the settings: storage analysis that shows what is filling the phone, and a backup service that copies the user's data to an account. One device, all five management tasks.

Spooling: one printer shared by an office

In an office where several computers share one laser printer, nobody waits for the printer before they can carry on typing. When a document is printed, the operating system writes it to a spool file on disk and adds it to a queue; the print spooler then sends the jobs to the printer one at a time. The application that produced the document has finished with it, so the processor is free, and a second user can send a job while the first is still printing. Without spooling, each computer would have to hold the printer for the whole of its document, and a slow printer would hold up the machine that sent the job. This is the standard example of a management task that exists purely because devices are slower than the processor.

Shared library code: DLLs in Windows

Windows programs do not each contain their own copy of the code that draws a standard dialogue box, reads a file or displays an error message. That code sits in dynamic link libraries, and a program records which DLLs it needs; when it starts, the operating system loads them into memory and the program calls into them. Because several running programs use the same DLL, only one copy of it needs to be in memory, and Microsoft can issue a corrected DLL that improves every program using it without those programs being recompiled. The weakness is equally real: a program that needs a DLL which is missing, or which is a different version from the one it was built against, fails to start and reports the name of the file. This is the example to use for both the benefit and the drawback of library files.

Partly compiled, partly interpreted: Java and the JVM

A Java program is written in a .java source file and compiled by javac. The compiler does not produce machine code for the computer it runs on; it produces bytecode in a .class file, which is code for a virtual machine rather than for a processor. When the program is run, the Java Virtual Machine on that computer loads the bytecode and executes it, interpreting it or compiling the parts used most into machine code as it goes. So the same .class file runs on Windows, macOS and Linux without being recompiled, while syntax errors were still caught before anything ran and the source code was never distributed. This is what the syllabus means by a program that is partially compiled and partially interpreted, such as Java in console mode.

An IDE in use: Visual Studio

In Visual Studio, typing the name of an object and a dot brings up a list of that object's methods and properties, which is a context-sensitive prompt; errors such as a missing bracket are underlined as the code is typed, which is a dynamic syntax check; and the editor indents blocks automatically and lets a whole routine be collapsed to a single line, which is prettyprint and code folding. When a program misbehaves, the programmer sets a breakpoint on the suspect line, runs the program, and inspects the variables and watch expressions in the report window when execution pauses; from there the debugger can single step one statement at a time and the value of each variable can be seen changing. The point of the example is that all of these are features of the environment, not of the language, and each one saves the programmer a specific piece of work.

Flashcards

Click a card to flip it. Mark honestly — the tracker uses this.

Q1Why does a computer system require an operating system?
Because the resources of the machine are limited and must be shared. The OS allocates processor time, memory, storage and peripherals between programs and keeps them apart, hides the complexity of the hardware through drivers and standard services, provides a user interface, enforces security through accounts and permissions, handles errors, and provides the platform that application software is written against.
Q2What does memory management involve, and what does process management involve?
Memory management: keeps track of which memory is free and which is in use, allocates a block to a program when it is loaded, frees it when the program ends, prevents one program overwriting another, and makes room by moving unused data to backing store when memory is full. Process management: a process is a program being executed; the OS decides which process uses the processor and for how long, switches between them so several appear to run at once, applies priorities, and closes processes that finish or crash.
Q3What tasks does the operating system's file management carry out?
It maintains the directory structure of folders and files, records where on the disk each file's blocks are stored, and provides create, open, save, copy, rename, move and delete. It stores each file's metadata (name, size, type, dates) and its access rights, and it tracks which blocks are free so that space can be allocated as a file grows.
Q4What is security management in an operating system?
Controlling who may use the system and what they may do: user accounts with usernames and passwords, privilege levels (administrator or standard user), read/write/execute permissions on files, folders and devices, isolation of one process's memory from another, and logs of logons and file access. It cannot protect data from a user who is entitled to see it, or a disk that is physically removed.
Q5How does the operating system manage peripherals, and what are buffering and spooling?
Each device has a device driver, supplied with the hardware, that tells the OS how to send commands and read data, so a program can use the device without knowing how it works. A buffer is an area of memory holding data during a transfer so the processor does not wait for a slow device. Spooling queues whole jobs, usually print jobs, on disk and sends them to the device one at a time, so several users can share one printer.
Q6Name the utility programs supplied with an operating system and say what each does.
Disk formatter: prepares a disk, sets up the file system, marks bad sectors, removes existing data. Virus checker: scans for known malware against a signature database and quarantines or deletes it. Defragmentation: makes each file contiguous on a magnetic disk so it reads faster. Disk contents analysis: shows what is using space. Disk repair: checks and fixes file system errors and bad sectors. File compression: reduces file size. Back-up: copies files to another medium so they can be restored.
Q7Why is defragmentation needed on a hard disk but not on a solid-state drive?
On a magnetic hard disk the read/write head must physically move to each block, so a file whose blocks are scattered takes longer to read; defragmentation rewrites the blocks so each file is contiguous and free space is collected together. A solid-state drive has no moving parts and the same access time wherever data is stored, so there is nothing to gain, and the extra writes shorten the drive's life, so the OS uses TRIM instead.
Q8What is a program library, and what are the benefits to the developer?
A collection of pre-written, tested routines that a program can call instead of writing the code itself. The developer saves development time, inherits code that has already been tested and debugged by specialists, gets routines that are efficient and handle awkward cases, writes shorter and clearer code, and gains any correction made to the library later.
Q9What is a DLL and what are the benefits and drawbacks of using one?
A dynamic link library keeps its code in a separate file which the OS loads into memory when a program that needs it runs. Benefits: the executable is smaller because the code is not copied in, one copy in memory can be shared by several programs, and the DLL can be updated without recompiling the programs. Drawbacks: the program will not run if the DLL is missing or the wrong version, and a faulty DLL can affect every program that loads it.
Q10What does an assembler do, and why is assembly language machine-specific?
It translates an assembly language program into machine code: each mnemonic is replaced by its opcode, and each label is replaced by the address it represents. Because the translation is close to one instruction for one instruction, and the mnemonics and instruction set belong to one processor family, a program written for one processor will not run on another.
Q11Give the benefits and drawbacks of a compiler and of an interpreter.
Compiler: translates the whole program before it runs and produces an executable, so the program runs fast, needs no translator and the source can be withheld, and all errors are reported at the end of compilation; but nothing runs until it compiles, every change needs a recompile, and the executable is specific to one platform. Interpreter: translates and executes a statement at a time with no compile stage and stops at the exact error, which suits development; but it is slower at run time, the interpreter must be installed, and the source is visible.
Q12How is a Java program partly compiled and partly interpreted, and what does an IDE provide?
Java is compiled to bytecode, which is code for a virtual machine rather than for a processor, and the Java Virtual Machine on the target computer then interprets the bytecode or compiles the parts used most into machine code as it runs - so errors are caught before running, the source is not distributed, and the same bytecode runs on any platform with a JVM. An IDE provides an editor with context-sensitive prompts, dynamic syntax checks as you type, prettyprint and collapsible code blocks, and a debugger with single stepping, breakpoints and a variables and expressions report window.
0 of 12 marked as known

Exam-style questions

8 questions, 30 marks. Write your answer, then reveal the mark scheme and tick each point you actually made. Answering honestly here is what makes the rest of the site useful.

StateAO11 mark
State what is meant by a process.

Mark scheme — tick each point you actually made

Examiner tip: One mark, one definition. Do not describe process management or scheduling: the question asks what a process is, not what the operating system does with it.
IdentifyAO12 marks
Identify the type of translator used in each of the following situations. (a) A program written using mnemonics and labels is to be converted into machine code. (b) A whole high-level language program is to be converted into an executable file before it is supplied to customers.

Mark scheme — tick each point you actually made

Examiner tip: Both parts want the name of the translator only. Do not explain how it works, and do not offer two translators for one part - a second name cancels the mark.
ExplainAO15 marks
Explain the key management tasks carried out by an operating system.

Mark scheme — tick each point you actually made

Examiner tip: One paragraph per task, and each one needs what the OS does, not just the name of the task. The mechanism earns the mark: allocates and frees memory, prevents overwriting, loads drivers, decides which process runs.
DescribeAO23 marks
A student's magnetic hard disk has become badly fragmented and he also suspects that some of the files stored on it are damaged. Describe how the defragmentation software and the disk repair software supplied with the operating system can help him.

Mark scheme — tick each point you actually made

Examiner tip: Say what fragmentation is before you say what defragmentation does, and finish with the effect on access time. For the damaged files, the marks are for checking the file system, repairing errors and marking bad sectors - not for making a backup, which is a different utility.
CompareAO24 marks
Compare the use of a compiler with the use of an interpreter to run a high-level language program.

Mark scheme — tick each point you actually made

Examiner tip: Every point must mention both translators, because the command word is compare. Four separate pairs of statements, each pair covering the same feature - translation, run-time speed, error reporting, distribution - is what a full-mark answer looks like.
ExplainAO24 marks
A developer is writing a program that uses routines from a dynamic link library (DLL). Explain the benefits to the developer of using the DLL rather than writing the routines into the program.

Mark scheme — tick each point you actually made

Examiner tip: The mark is for the mechanism and its consequence, so link the two in one sentence. A DLL is a library earns nothing; the code is not copied into the executable, so the executable is smaller earns the mark.
JustifyAO25 marks
A software company is writing a program that will be sold to thousands of customers, who will run it on their own computers and will not be given the source code. A second team is writing a program that is still being developed and tested, and is changed many times each day. Justify the choice of translator for each team.

Mark scheme — tick each point you actually made

Examiner tip: Justify means name the choice and then give the reason that comes from the situation described - selling software, hiding source, developing and testing. A general list of compiler advantages with no reference to either team scores about half.
DescribeAO26 marks
Describe how each of the following features of an integrated development environment (IDE) helps a programmer. (a) context-sensitive prompts (b) dynamic syntax checks (c) prettyprint (d) expand and collapse code blocks (e) single stepping (f) breakpoints

Mark scheme — tick each point you actually made

Examiner tip: One mark per feature, and each answer needs what the feature does for the programmer, not a restatement of its name. Dynamic syntax checks are not the same as compiler error reporting: they happen while the code is being typed, before anything is compiled.

Exam technique for this topic

  • For a question about why an operating system is required, pair every point with the mechanism behind it: it manages memory so that two programs cannot overwrite each other, and it provides device drivers so that a program can print without knowing anything about the printer. A list of the five management tasks with no reason attached scores about half.
  • When asked for key management tasks, name the task and then say what the operating system actually does, with one concrete example - a block of memory allocated to a program, a file's access rights, a print queue. Writing only memory management, file management, security management earns one mark at most.
  • Compiler and interpreter answers must be comparative sentences. A compiler translates the whole program at once is a description; a compiler translates the whole program before it runs, so the program runs faster because the translation is not repeated is a comparison, and comparisons are what the question is asking for.
  • For a justify question, choose first - compiler or interpreter - and then give the reason that follows from the scenario. Software sold to thousands of users means a compiler, for speed without a translator and for hiding the source; a program still being developed means an interpreter, because it stops at the line with the error and needs no compile step.
  • For IDE features, link each one to the activity it supports: writing code (context-sensitive prompts), checking before running (dynamic syntax checks), reading code (prettyprint, collapse blocks), finding a fault (single stepping, breakpoints, the variables and report window). Adding the phrase so that the programmer can... turns a name into a mark.

Why students lose marks here

A student wroteA student wrote: 'A computer needs an operating system because it is the software you use to write documents, browse the internet and send email.'
Why it loses marksThose are application programs. The operating system is the system software underneath them, and the reasons the syllabus wants are about managing resources, hiding the hardware and providing a platform for those applications to run on.
The answer that scoresA computer needs an operating system because the resources of the machine are limited and shared. The OS allocates processor time and memory to each program and keeps programs apart, so that one cannot overwrite another's data; it manages files and storage, decides who may access them, and controls the peripherals through device drivers so that a program can print without knowing how the printer works. It provides the user interface and the platform that application software is written against, and it handles errors so that a single faulty program does not stop the machine. A word processor is application software: it needs the operating system, not the other way round.
A student wroteA student wrote: 'The operating system translates the program into machine code and then runs it.'
Why it loses marksTranslation is the job of a translator - an assembler, compiler or interpreter - not of the operating system. The OS loads a program that is already in machine code and gives it processor time; it does not convert source code into machine code.
The answer that scoresA translator converts the program into machine code. An assembler translates an assembly language program, a compiler translates a whole high-level language program into an executable before it is run, and an interpreter translates and executes a high-level language program one statement at a time. The operating system's part comes afterwards: it loads the executable (or loads the interpreter, which then loads the source file), allocates it memory, and schedules the resulting process on the processor. Mixing the two up loses marks in both parts of the question.
A student wroteA student wrote: 'An interpreter is used to distribute software because it produces an executable file that the user can run.'
Why it loses marksAn interpreter does not produce an executable file at all: it translates and executes the source one statement at a time and saves nothing. Distribution is the compiler's advantage, precisely because the customer receives machine code and not source code.
The answer that scoresA compiler produces an executable file of machine code, and that file can be supplied to a user who has neither the compiler nor the source code; the code is therefore protected and the program runs quickly. An interpreter produces no separate translated file. It reads the source program and executes each statement as it translates it, so the user needs the interpreter installed and can read the source code. That makes an interpreter suitable for development and for teaching, where immediate feedback on the statement containing an error matters more than run-time speed, and a compiler suitable for software that is to be sold and run by people who must not see the code.
A student wroteA student wrote: 'The defragmentation software should be run every week on a solid-state drive to keep it fast.'
Why it loses marksDefragmentation works by moving blocks so that a file's parts are next to each other, which shortens the distance the read/write head of a magnetic disk has to travel. A solid-state drive has no head and no moving parts, so there is no access time to save, and the extra writing uses up the drive's limited write cycles.
The answer that scoresDefragmentation is for magnetic hard disks. As files are created, resized and deleted, the blocks belonging to one file become scattered across the disk, so reading the file requires the read/write head to move to several places; defragmentation rewrites the blocks so that each file is contiguous and the free space is collected together, which reduces head movement and speeds up access. A solid-state drive stores data in flash memory with no moving parts and the same access time wherever the data is, so defragmentation brings no speed benefit and the additional writes shorten its life. The operating system uses TRIM on a solid-state drive instead, to tell the drive which blocks are no longer needed.
A student wroteA student wrote: 'A program that uses a DLL is smaller because the library code is copied into the executable when it is compiled.'
Why it loses marksThe sentence contradicts itself and reverses how a DLL works. If the code were copied in, the executable would be larger - that is what happens with a static library. The whole point of a DLL is that the code is not copied in but loaded at run time.
The answer that scoresWith a dynamic link library the routine's code stays in a separate file. The program records that it needs the DLL, and when the program runs the operating system loads the DLL into memory and the program calls into it. Because the code is not copied into the executable, the executable is smaller and takes less disk space; one copy of the DLL can be shared in memory by several programs running at once; and the DLL can be replaced with a corrected version without the programs being recompiled. A static library works the other way: the code is copied in at link time, so the executable is larger but does not depend on a separate file being present.