The worksheetDownload the PDF
Answers

F9.9 Operating systems and utilities

Logic and computer systems · GCSE · OCR J277 1.5.1, AQA 8525 3.4.3, Edexcel 1CP2 3.2.1 · about 15 min

BugBotLab

What this lesson is about

What an operating system does, scheduling, and utility software.

Questions 6 marks in all

  1. [1 mark]What is a device driver?

    1. AA program that lets the operating system talk to a particular device
    2. BA person who fixes hardware
    3. CA utility that speeds up the disk
    4. DThe part of the CPU that controls devices
    Answer: A. Each printer or camera needs its own driver.
  2. [1 mark]How does an operating system run several programs on one core?

    1. AIt gives each a short time slice and switches between them quickly
    2. BIt runs them all at the same instant
    3. CIt runs one program to the end before starting the next
    4. DIt copies each program to a separate core
    Answer: A. The switching is so fast they seem to run at once.
  3. [1 mark]What does defragmentation do?

    1. AMoves the pieces of each file on a hard disk back together
    2. BRemoves viruses
    3. CMakes files smaller
    4. DCopies files to another drive
    Answer: A. Fewer head movements means faster reading.
  4. [1 mark]Why should an SSD not be defragmented?

    1. AIt gains no speed and the extra writes wear it out
    2. BIt deletes the files
    3. CSSDs cannot store files in pieces
    4. DIt makes the SSD volatile
    Answer: A. There is no moving head to benefit.
  5. [1 mark]What does an incremental backup copy?

    1. AOnly the files changed since the last backup
    2. BEvery file on the computer
    3. COnly the operating system
    4. DOnly files that have been deleted
    Answer: A. Faster than a full backup, but restoring needs every backup.
  6. [1 mark]What does this program print?

    queue = ["a", "b", "c"]
    job = queue.pop(0)
    queue.append(job)
    print(queue)
    Answer:
    ['b', 'c', 'a']

    The job at the front moves to the back: round robin.

The task: a round-robin scheduler

Write a round-robin scheduler with a time slice of 2 units. Each job in jobs needs some units of processor time. Take the job at the front of the queue, run it for 2 units or for what it has left, whichever is less, and print <name> ran for <n>. If it is not finished, put it at the back of the queue; if it is, print <name> finished at <t>, where t is the total time so far.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

jobs = [("motors", 3), ("camera", 5), ("radio", 2)]
time_slice = 2

The hint students can ask for: Take the job at the front of the queue and run it for the slice, or for what it has left if that is less. Add the time on, then either put it back at the end of the queue or announce it has finished.

A solution

from bugbot import *
connect()
jobs = [("motors", 3), ("camera", 5), ("radio", 2)]
time_slice = 2
queue = list(jobs)
t = 0
while queue:
    name, left = queue.pop(0)
    run = min(time_slice, left)
    t = t + run
    print(name, "ran for", run)
    if left - run > 0:
        queue.append((name, left - run))
    else:
        print(name, "finished at", t)

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.