Tech●●●●●Difficulty 3 of 5

How does one processor seem to do many things at once?

Your computer has only a few processor cores but runs dozens of programs. It is a magic trick, and the magician is the scheduler.

▶ Start the story

One processor seems to do many things at once because it does them one at a time, in tiny slices, and switches so fast that you cannot see the joins. This is : give each task a small slice of processing time, and the quick switching gives the illusion of simultaneous execution. The part of the operating system that decides whose slice comes next is the scheduler, and scheduling is what makes multitasking possible with a single CPU.

Picture one teacher marking the work of thirty pupils by giving each a few minutes in turn, over and over. Every pupil feels the teacher is always there for them, though only one is being helped at any moment. On a computer the slices are measured in milliseconds: a thread's turn is often capped at 100 to 200 when others are waiting, and switching happens often enough that you perceive the programs running in parallel.

The idea was invented because the alternative was miserable. In the , a programmer's work could take days to run, and the programmer might never see the computer. Letting someone sit at the machine directly was far too expensive, since the computer stayed idle while the user typed. fixed that: the first interactive system for software development, CTSS, was started at MIT by John McCarthy's memo in 1959, and Fernando Corbató led it to a working prototype by 1961.

Before and after time-sharing

Batch era

  • Programs handed to an operations team
  • Results could take days
  • Programmer might never see the computer

Time-sharing

  • Many users share one computer in small slices
  • Interactive: the machine answers back
  • Pioneered by CTSS at MIT, 1959–1961

Each switch means saving the state of the running program and loading another's, which is called a . It costs time, so a good scheduler balances fairness against speed.

Quiz me

0/3

  1. 1.How can a single CPU core seem to run many programs at the same moment?
  2. 2.Why did early programmers often wait days to see a result?
  3. 3.What can a preemptive scheduler do that a cooperative one cannot?

Recap

One processor, many programs: tiny turns, switched so fast that it looks simultaneous.

💡 A trick to remember it · A teacher marking thirty exercise books a few minutes at a time, so every pupil feels attended to.

Surprising fact · Before time-sharing, a programmer's job could take days and the programmer might never see the computer.

Sources (6)

No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.

  1. [1]Time-sharing · Wikipedia
  2. [2]Scheduling (computing) · Wikipedia
  3. [3]Round-robin scheduling · Wikipedia
  4. [4]Thread (computing) · Wikipedia
  5. [5]Context switch · Wikipedia
  6. [6]Process (computing) · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗