What is time sharing in an OS
You listen to music, write a document, and download a file. It all seems to happen at once, but there's actually only one worker (CPU). Because it switches between them in tiny slices very quickly, it looks to us as if everything is happening at the same time.
Everyone wants to use it
Play music, write a document, download a file: all three need the worker (CPU).
But there's only one worker, so the three can't use it all at once.
What can be done?
Three jobs, but only one worker.
In lesson 2 we saw that a running program is a process.
Right now there are three processes and one worker. How the three share that one worker is what this lesson is about.
Taking short turns
Here's how it works. The worker handles the music for a moment, the document for a moment, the file for a moment.
It does a tiny bit, moves on to the next job, and goes around and around.
Press the button and watch.
The worker takes short turns → all three make a little progress.
It only does one thing at a time. But because it switches so quickly, all three seem to move forward without stopping.
In fact, the worker is going back and forth between jobs without a break.
An illusion made by speed
The secret is speed. If the switching is slow, you can see the turns and think, "Ah, it's doing one at a time."
But if the switching is very fast, the human eye can't see the breaks, so it feels simultaneous.
Change the switching speed and see how the picture changes.
A real computer switches its worker thousands of times a second. People simply can't sense that speed.
So we believe it's "at the same time," but it's actually incredibly fast turn-taking.
Your device does this too
The device you're reading this on is no different. It draws the screen, plays sound, and checks connections.
It looks as if dozens of jobs are running together, but one worker is switching between them quickly.
On your device right now, one worker takes turns.
The smoothness we feel as "many things at once" is the result of an invisible caretaker slicing the worker finely and sharing it out.
The operating system does this behind the scenes.
Fast turns: that one idea
The key idea of this lesson is just one: even with a single worker, fast turn-taking looks like doing many things at once. This is time-sharing.
But to take turns, wouldn't you have to stop what you were doing and pick it up again later?
Once you know about taking turns, here's the next question.
Because the operating system slices the worker finely, we can enjoy many tasks on a single computer.
This simple trick of "one pretending to be many" makes computers far more useful.