KS5H446 1.2.1 32 min read 10 question quiz 21 exam marks

Systems Software

Operating system functions, memory management and paging, every scheduling algorithm, interrupts, and the four types of operating system.

Memory management and scheduling

Memory management

The operating system must decide what occupies physical memory and where.

Paging divides memory into fixed size pages and physical memory into equally sized frames. Any page can go in any frame, so pages of a process need not be contiguous. A page table maps logical page numbers to physical frame numbers.

Segmentation divides memory into variable sized segments that reflect the logical structure of the program, such as a function, an array or a module.

PagingSegmentation
SizeFixedVariable
Divided byThe operating systemThe logical structure of the program
FragmentationInternal, since the last page is rarely fullExternal, as gaps appear between segments
AddressPage number plus offsetSegment number plus offset

Virtual memory uses secondary storage to hold pages that do not fit in RAM. When a required page is absent a page fault occurs, the operating system loads it, evicting another page if necessary. Excessive page faults cause disk thrashing.

Scheduling

The scheduler decides which process gets the processor and for how long, aiming to maximise throughput, keep the processor busy, be fair and stay responsive.

AlgorithmHow it worksStrengths and weaknesses
Round robinEach process gets a fixed time slice in turnFair and responsive, but ignores priority and urgency
First come first servedProcesses run in arrival order until they finish or blockSimple, but one long job blocks everything behind it, the convoy effect
Shortest job firstThe process with the shortest total time runs nextBest average waiting time, but requires knowing run times in advance and can starve long jobs
Shortest remaining timePre-emptive version of shortest job firstVery responsive, but high overhead and worse starvation
Multi level feedback queuesSeveral queues of differing priority, with processes moved between them based on behaviourFlexible and adaptive, but complex to tune
Pre-emptive against non pre-emptive

A pre-emptive scheduler can interrupt a running process to give the processor to another. Round robin, shortest remaining time and multi level feedback queues are pre-emptive. First come first served and shortest job first are not.

Virtual memory: pages moved between RAM and diskVirtual memory, drawn as pages moving between two levels. RAM holds the parts of the running programs that are needed now: it is fast, volatile and small. The disk below is slow, permanent and enormous. When another program is started and there is no space left in RAM, the operating system picks a page that has not been used recently and writes it out to a reserved area of the disk, which is the swap space or page file. That frees real memory so the new program can start. If the page that was swapped out is needed again, it has to be fetched back from the disk, which is thousands of times slower than RAM, and that is why a computer that is short of memory and swapping constantly feels so slow.RAM: fast, and smallDisk: slow, and hugeA1A2B1B2C1C2A3C3not used latelyswap space (the page file)B4A7C3Program Dopening nowno room left!needed againdisk is slowso the computerfeels sluggish12345
  1. RAM holds the programs that are running. It is fast, and it is small.
  2. Open one program too many and there is no room left.
  3. A page that has not been used lately is written out to the disk.
  4. That frees real memory, so the new program can start.
  5. Needed again, the page is fetched back, which is why it goes slow.
Virtual memory does not make a machine faster. It lets it run more than will fit, and pays for that in disk time.
Three scheduling algorithms run on the same three jobsThree jobs arrive together: A needs 5 time units of processor time, B needs 3 and C needs 2. Each scheduling algorithm is drawn as a chart of who has the processor over time. First come first served runs A for 0 to 5, B for 5 to 8 and C for 8 to 10. The long job A makes the others wait, the average wait is 4.3 and the last job does not start until time 8. Shortest job first runs C for 0 to 2, B for 2 to 5 and A for 5 to 10. It has the lowest average wait, 2.3, but it must know how long each job is in advance. Round robin with a time slice of 2 runs A, B, C, A, B, A for slices of 2, 2, 2, 2, 1 and 1. It is fair, every job has started by time 4, but the average wait is 5.0.Three jobs arrive together:A needs 5B needs 3C needs 2time units of CPUFirst come first servedABC05810avg wait 4.3all started by 8long job blocks others1Shortest job firstCBA02510avg wait 2.3all started by 5must know the lengths2Round robin, slice of 2ABCABA02468910avg wait 5.0all started by 4fair share of the CPU3Wait = time spent waiting for the CPU before the job finishes.
  1. First come first served: jobs run in arrival order, so the long job A holds up B and C.
  2. Shortest job first: the lowest average wait, but it needs to know the lengths and can starve long jobs.
  3. Round robin: each job gets a short slice in turn, so everyone starts quickly and shares the CPU fairly.
There is no best algorithm. Each trades fairness, response time and average waiting time.

Types of operating system and other functions

Types

  • Distributed. One system spread across multiple networked machines, sharing work and appearing to the user as a single system.
  • Embedded. Built for one dedicated task, minimal, stored in ROM, highly reliable and low power.
  • Multi tasking. Several processes appear to run at once through rapid context switching between them.
  • Multi user. Several users share one system simultaneously, requiring scheduling and access control to keep them separated fairly.
  • Real time. A guaranteed maximum response time, essential where a late answer is a wrong answer, as in an anti lock braking system or a pacemaker.

Other operating system functions

  • Interrupt handling. The end of cycle check, saving state to a stack, running the interrupt service routine, restoring state.
  • Device drivers. Translating generic operating system instructions into commands a specific hardware device understands, which is why the same operating system supports thousands of printers.
  • File management. Directory structure, permissions, allocation of blocks, and tracking free space.
  • Security. Authentication, access rights, encryption support and auditing.

The BIOS and the boot process

  1. Power on. The processor begins executing at a fixed address in ROM.
  2. The BIOS or UEFI firmware runs a power on self test, checking that essential hardware responds.
  3. It identifies the boot device and loads the bootstrap loader from it.
  4. The bootstrap loads the operating system kernel into RAM.
  5. Control passes to the kernel, which initialises drivers, memory management and the user interface.

Virtual machines

A virtual machine is a software implementation of a computer.

  • Intermediate code, such as Java bytecode, is executed by a virtual machine, so the same compiled code runs on any platform with a suitable VM. The cost is slower execution than native code.
  • System virtual machines run a complete guest operating system in software, allowing several operating systems on one physical machine, sandboxed testing of untrusted software, and consolidation of servers.
What the operating system does, between the applications and the hardwareThe operating system sits between the applications above it and the hardware below it, with an arrow from the applications down into the operating system and another from the operating system down to the hardware. Six jobs surround it. Memory management decides which program gets which part of RAM. Processor scheduling shares the CPU between the running programs. File management looks after folders, names and where data is stored. Device drivers let programs use printers, screens and disks. Security handles log-ins, accounts and who can open what. The user interface provides windows, icons and menus, or typed commands.Memorydecides which programgets which part of RAMCPUProcessor timeshares the CPU betweenthe running programsFilesfolders, names andwhere data is storedDevicesdrivers let programs useprinters, screens, disksSecuritylog-ins, accounts andwho can open whatUser interfacewindows, icons, menusor typed commandsApplicationsHardwareOperatingsystem123
  1. The operating system sits between the applications and the hardware, so a program never has to deal with the hardware directly.
  2. It shares out the computer's resources: memory, processor time and storage.
  3. It also talks to devices through drivers, keeps the system secure and provides the user interface.
Most exam answers on the operating system are a list of these jobs with one sentence on what each one does.

Key terms you must be able to define

Paging
Dividing memory into fixed size pages mapped to equally sized physical frames.
Segmentation
Dividing memory into variable sized segments reflecting the logical structure of a program.
Page fault
An event raised when a required page is not present in physical memory.
Scheduler
The operating system component deciding which process runs and for how long.
Pre-emptive
A scheduling approach that can interrupt a running process to give the processor to another.
Round robin
Scheduling giving each process an equal time slice in turn.
Starvation
A process never receiving processor time because others are continually prioritised.
Device driver
Software translating operating system instructions into commands for specific hardware.
Real time operating system
An operating system guaranteeing a maximum response time.
Virtual machine
A software implementation of a computer, used to run intermediate code or a guest operating system.
BIOS
Firmware that performs the power on self test and loads the bootstrap loader.

Flashcards

Say the definition out loud before you flip the card. Retrieving it from memory is what builds recall, reading it again is not.

DefinePaging
AnswerDividing memory into fixed size pages mapped to equally sized physical frames.
DefineSegmentation
AnswerDividing memory into variable sized segments reflecting the logical structure of a program.
DefinePage fault
AnswerAn event raised when a required page is not present in physical memory.
DefineScheduler
AnswerThe operating system component deciding which process runs and for how long.
DefinePre-emptive
AnswerA scheduling approach that can interrupt a running process to give the processor to another.
DefineRound robin
AnswerScheduling giving each process an equal time slice in turn.
DefineStarvation
AnswerA process never receiving processor time because others are continually prioritised.
DefineDevice driver
AnswerSoftware translating operating system instructions into commands for specific hardware.

Reach the top grade on this topic

  • Compare paging and segmentation on size, who decides the division, and the kind of fragmentation each causes
  • Name each scheduling algorithm with both a strength and a weakness, including starvation and the convoy effect
  • Identify which algorithms are pre-emptive and explain what that means
  • Explain intermediate code and virtual machines in terms of portability against execution speed
  • Explain a real time operating system as one where a late answer is a wrong answer

Mistakes that cost marks here

Avoid these
  • Saying paging and segmentation are the same. Pages are fixed size and decided by the OS, segments are variable and follow program structure.
  • Describing round robin as efficient. It is fair and responsive, which is a different property.
  • Forgetting starvation as the weakness of shortest job first.
  • Saying a real time OS is simply fast. It guarantees a maximum response time.
  • Saying intermediate code runs everywhere with no cost. It executes more slowly than native code.
Fun fact

Round robin scheduling was designed to be fair, not fast. Every process gets an equal slice whether it needs a microsecond or an hour, which is exactly what makes an interactive system feel responsive.

Knowledge check

0 of 10 answered
1What is the key difference between paging and segmentation?
2What is a page fault?
3Which scheduling algorithm can cause starvation of long processes?
4What is the convoy effect?
5Which scheduling algorithm is NOT pre-emptive?
6What defines a real time operating system?
7What is the purpose of a device driver?
8What is the main advantage of intermediate code such as Java bytecode?
9During booting, what does the BIOS do first?
10Round robin scheduling is best described as:
Score 0 / 10

Exam-style questions

Five written questions in the style of the real paper. Write a full answer, then let the marker check it against the mark scheme.

21 marks
1Explain the difference between paging and segmentation.4 marks
Explain

Mark scheme0 / 4
  • LPages are fixed size divisions of memory
  • LSegments are variable in size
  • LPaging is decided by the operating system regardless of program structure
  • LSegmentation follows the logical structure of the program such as functions or arrays
Model answer

Paging divides memory into fixed size blocks called pages, with physical memory divided into frames of exactly the same size, so any page can be placed in any free frame. The division is made by the operating system purely on the basis of size and takes no account of what the memory contains, which means a single function might be split across two pages. Segmentation instead divides memory into variable sized segments that correspond to the logical structure of the program, so one segment might hold a particular function, another an array and another the stack. Because segments vary in size, allocating and freeing them leaves gaps between them, producing external fragmentation, whereas paging produces internal fragmentation because the final page of an allocation is rarely completely full.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
2Describe how round robin scheduling works and state one advantage and one disadvantage.4 marks
Describe

Mark scheme0 / 4
  • LEach process is given a fixed time slice or quantum
  • LWhen the slice expires the process is pre-empted and moved to the back of the queue
  • LAdvantage: it is fair and gives good responsiveness for interactive processes
  • LDisadvantage: it ignores priority and urgency, and context switching adds overhead
Model answer

In round robin scheduling every ready process is placed in a queue and each is given the processor for a fixed period known as a time slice or quantum. When that slice expires the process is pre-empted, its state is saved, and it is moved to the back of the queue while the next process runs. The cycle continues so that every process receives processor time regularly. Its main advantage is fairness and responsiveness: no process can monopolise the processor and none can be starved, which makes an interactive system feel consistently responsive to user input. Its main disadvantage is that it takes no account of priority or urgency, so a critical process waits exactly as long as a trivial one, and the frequent context switching consumes processor time that does no useful work, which becomes significant if the quantum is set too short.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
3Explain what is meant by a real time operating system and give an example of where one would be used.3 marks
Explain

Mark scheme0 / 3
  • LIt guarantees a response within a defined maximum time
  • LA late response is treated as a failure even if it is correct
  • LGives a valid example such as anti lock brakes, a pacemaker or industrial control
Model answer

A real time operating system is one that guarantees a response to an event within a defined maximum time, rather than merely aiming to be fast on average. The essential property is determinism: the worst case response time is known and bounded. In such a system a correct result delivered after the deadline counts as a failure, because the moment for acting has already passed. An anti lock braking system is a clear example: when a wheel locks, the controller must reduce brake pressure within milliseconds, and a decision arriving even slightly late is worthless because the vehicle has already skidded. Other examples include pacemakers, aircraft flight control systems and industrial machinery controllers.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
4Explain the advantages and disadvantages of using intermediate code executed by a virtual machine.5 marks
Explain

Mark scheme0 / 5
  • LThe source is compiled once into platform independent intermediate code
  • LThe same code runs on any platform that has a suitable virtual machine
  • LThis removes the need to compile separately for every target platform
  • LExecution is slower than native machine code because of the translation layer
  • LA virtual machine must be installed on the target system
Model answer

With intermediate code, the source is compiled once into a platform independent form such as Java bytecode rather than into the machine code of a particular processor. The main advantage is portability: the same compiled file will run on Windows, macOS, Linux or a mobile platform provided a suitable virtual machine is present, so the developer maintains and distributes one version rather than building and testing a separate binary for every target. This substantially reduces development and distribution effort, and it also allows the virtual machine to provide a controlled sandbox, which improves security. The principal disadvantage is performance. The virtual machine must translate the intermediate code to native instructions as the program runs, and this additional layer means execution is slower than equivalent natively compiled code, even with just in time compilation reducing the gap. There is also a dependency cost, since the appropriate virtual machine must be installed on the target system before the program will run at all, and the program cannot access platform specific hardware features directly.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
5Describe the sequence of events that occurs when a computer is switched on.5 marks
Describe

Mark scheme0 / 5
  • LThe processor begins executing firmware from a fixed address in ROM
  • LA power on self test checks that essential hardware is present and working
  • LThe firmware identifies the boot device
  • LThe bootstrap loader is loaded and run
  • LThe operating system kernel is loaded into RAM and takes control
Model answer

When power is applied, the processor begins executing instructions from a fixed address which points into ROM, so the first code to run is firmware rather than anything on the disk. That firmware, the BIOS or UEFI, performs a power on self test which verifies that essential hardware such as memory, the processor and the display adapter are present and responding, halting with an error if anything critical fails. It then consults its configuration to determine the boot order and identifies the device to boot from. The bootstrap loader is read from that device into memory and executed, and its job is to locate and load the operating system kernel into RAM. Control is then transferred to the kernel, which initialises memory management, loads device drivers, starts system services and finally presents the user interface.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
Machine mark 0 / 21