One pretending to be many
Music playing, writing a doc, a download too. Seems like all at once, right? Really, the worker (CPU) is just one. It switches between them so fast, a little at a time, that to our eyes it looks like it all happens together.
Everyone wants a turn
Play music,
write a doc,
download a file.
All three need the worker (CPU).
But there's only one worker.
Three can't use
one worker all at once.
So what do we do?
Three jobs · only one worker.
Saw it in lesson 2?
A running program is a process.
Right now there are three processes,
but one worker.
How three share
this one,
that's today's story.
Take quick turns
Here's how.
The worker does music a moment,
the doc a moment,
the file a moment.
A tiny bit each,
then on to the next.
Around once, then again.
Press the button and watch.
The worker switches a little at a time → all three inch forward.
It does one at a time.
But it switches so fast
that all three seem
to move without stopping.
The worker is really
going back and forth
between jobs without rest.
The illusion that speed makes
The trick is speed.
Switch slowly
and you see all the taking turns.
"Ah, one at a time."
But switch very fast
and to human eyes
the gaps vanish.
So it feels simultaneous.
Move the switching speed.
A real computer
switches the worker
thousands of times a second.
People can't feel
that speed at all.
So we believe it's all at once.
Really it's very fast
taking turns.
Your device does this too
The very device
you're reading this on does the same.
Drawing the screen,
making sound,
checking the connection.
Dozens of jobs
seem to run,
but the worker is switching fast.
On your device right now (one worker taking turns).
Amazing, right?
That smoothness we feel
as many at once
is really an unseen housekeeper
slicing the worker fine
and sharing it out.
The operating system
does this behind the scenes.
Fast turns, that one thing
Today's one thing is this.
Even with one worker,
switching fast
makes many look simultaneous.
This is time-sharing.
But to take turns,
you'd have to stop a job
and pick it up again, right?
Once you know taking turns, now.
Thanks to the OS
slicing the worker fine,
we enjoy many jobs
on one machine.
"One pretending to be many."
This simple trick
makes a computer far more useful.