Three things at once
Your phone plays music. A chat message arrives. A game is open too.
One small processor does all of this. Who decides what runs and when? The operating system is the main program that runs the computer. Different jobs need different kinds of it.
Key words
| Word | What it means | Example |
|---|---|---|
| Operating system | The main program that runs the computer and shares its parts between programs. | Windows, Linux, Android |
| Batch | Running collected jobs later, one after another, with nobody waiting. | Printing 10000 bills (papers that say how much to pay) at night |
| Scheduling | Choosing which job runs next, and when. | Run the jobs in a set order |
| Multitasking | Running many programs at once. | Music and chat together |
| Time-slicing | Giving each program a very short turn on the processor, again and again. | 10 milliseconds each (1 millisecond is one thousandth of a second) |
| Interrupt | A signal that says "stop, I need attention now". | A key press |
| Real-time | Always answering within a fixed, short time. | A car airbag |
| Network | Computers joined to share things. | College Wi-Fi |
The cells students fill in are left blank in this preview.
Which kind of operating system?
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Five types at a glance
| Type | Main idea | Key features | Example use |
|---|---|---|---|
| Batch | Run big jobs later, with no user | No user waiting, very many jobs, scheduling | Paying wages, printing bills |
| Multitasking | Many programs seem to run together | Time-slicing, interrupts | A laptop or phone |
| Real-time | Always answer in time | Monitoring and control, transaction processing (payments and bookings) | Airbags, robots, card payments |
| Network | Look after a whole network | Resource sharing (many people use one printer or files), user management, communication | A college server |
| Mobile | Work well on small devices | Small processor, long battery life | Android, iOS |
The cells students fill in are left blank in this preview.
Batch and multitasking
A batch system has no user waiting. The jobs wait in a line (a queue). Scheduling decides the order. A company pays all its workers at night. Nobody types, and the machine stays busy.
Multitasking is different. You are there, and you want many things now. The processor gives each program a short turn. This is time-slicing. It happens so fast that all the programs seem to run together.
Try it: time-slicing
# The processor gives each task one short slice of time, in turn, again and again.
tasks = ["music", "chat", "game"]
for round_number in range(1, 4):
for name in tasks:
print("Round", round_number, "->", name, "gets a slice")
# Add a new task, such as "photos", and run it again.
Make a free account to save your work and track your progress.
What is an interrupt?
Note
You press a key while the processor is busy. The keyboard sends an interrupt. The processor pauses, does what the key asks, then goes back to its work. Without interrupts the computer would not notice you.
Extra: Meet a real operating system
uname -srA command for the lesson’s lab terminal. It is shown here and not run.
Extra: See many tasks at once
ps -e | head -8A command for the lesson’s lab terminal. It is shown here and not run.
Extra: Count the tasks
ps -e | wc -lA command for the lesson’s lab terminal. It is shown here and not run.
Extra: What you saw
Note
The first command named the operating system, Linux. The second listed tasks that run now. The third counted them. A small server already runs many tasks, and each one gets short turns on the processor.
Real-time means on time, every time
A real-time operating system must answer inside a fixed time. A late answer is a wrong answer.
It runs monitoring and control: an airbag, a factory robot, a heart monitor. It also runs transaction processing: a card payment or a plane seat booking must finish at once and without mistakes. A transaction is one payment or one booking.
Quick check: real-time
Have a go
Quick check: real-time
3 questionsA network system looks after a network
A network operating system runs on a server and looks after a whole network. A network is a group of computers joined together. It has three main jobs.
Resource sharing: many people use one printer or one file store.
User management: it knows each user and what they may open.
Communication: it passes messages between computers on the network.
Extra: Who does the system think you are?
whoamiA command for the lesson’s lab terminal. It is shown here and not run.
Extra: User management
Tip
The system printed the name of the account you are using. A network operating system keeps a list of accounts like this. It decides what each account may open. This is user management.
Extra: Who may use a shared folder?
ls -ld /srv/projectsA command for the lesson’s lab terminal. It is shown here and not run.
Extra: Read the first letters
Tip
The line starts with drwxr-xr-x. The d means a folder. Then come three groups of letters: the owner, the group and everybody else. The letter w means may write. Only the owner has it here. This is user management.
A mobile system saves battery
A mobile operating system runs on a smartphone or a tablet. Android and iOS are two examples.
These devices have a weaker processor and a small battery. So the system does less work that you cannot see. It also puts unused apps to sleep. This gives a longer battery life.
Your turn: choose the system
Write the function choose_os. It gets a short phrase that says what a computer needs. Give back the kind of operating system that fits: batch, multitasking, real-time, network or mobile. The starter lists the five phrases. Use if, elif and else. Any other phrase gives "unknown". Press Run Tests to check.
def choose_os(need):
# need is a short phrase. Give back the kind of operating system that fits it.
# "no user waiting" -> "batch"
# "many programs at once" -> "multitasking"
# "answer must be on time" -> "real-time"
# "share files and manage users" -> "network"
# "small battery" -> "mobile"
# Use if, elif and else. Anything else gives "unknown".
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Extra: Your turn: share the processor
A multitasking system gives each task a short turn, called a slice. Write the function run_order. It gets two lists: the names of the tasks, and how many slices each one needs. Each round, every task that is not finished gets one slice. Give back a list with the name of the task for each slice, in the order they run. For example, run_order(["music", "chat"], [2, 1]) gives ["music", "chat", "music"]. Press Run Tests to check.
def run_order(names, slices):
# names is a list of task names. slices is how many slices each task needs.
# Each round, every task that is not finished gets one slice, in list order.
# Give back a list with the name of the task for each slice, in the order they run.
# run_order(["music", "chat"], [2, 1]) gives ["music", "chat", "music"].
# Change None to your list.
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go