Logic and computer systems · GCSE · OCR J277 1.5.1, AQA 8525 3.4.3, Edexcel 1CP2 3.2.1 · about 15 min
What an operating system does, scheduling, and utility software.
[1 mark]What is a device driver?
[1 mark]How does an operating system run several programs on one core?
[1 mark]What does defragmentation do?
[1 mark]Why should an SSD not be defragmented?
[1 mark]What does an incremental backup copy?
[1 mark]What does this program print?
queue = ["a", "b", "c"] job = queue.pop(0) queue.append(job) print(queue)
['b', 'c', 'a']
The job at the front moves to the back: round robin.
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 = 2The 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.
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.