Lesson 1 · Unit 04
Processes
Running programs and how they take turns
What you practise
- A process is a running program with its own memory, PIDs, the scheduler and time slices, context switches, process versus thread in one line
Try a question from this lesson
Pick one
Your laptop has 8 cores, yet it is running around 400 programs and they all seem to make progress at once. How?
Correct answer
The OS switches each core between programs very rapidly
Why
Eight cores can only run eight things at any instant. The operating system gives each program a turn of a few milliseconds and switches so fast that it looks simultaneous.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
A process is a running program
A program is a file on disk. A process is one running copy of it: it has a process ID (PID), its own private memory, and its own saved registers and program counter for when it is paused.
Start a program twice and you get two separate processes.
PID COMMAND
1 init
412 python app.py
413 python app.pyConcept
The scheduler
The part of the OS that decides who runs next is the scheduler. It gives a process a short time slice, typically a few milliseconds. Then a hardware timer interrupts, the OS takes back the core, and the scheduler picks the next process.
A process waiting for the disk, the network or a key press is blocked: it needs no turn until its data arrives.
10 more exercises in the app
- 4× multiple choice
- 3× type the answer
- 1× true or false
- 1× match the pairs
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.