seegongsik
Saved words
Operating systems

Getting on speaking terms with any device

Up to lesson 10 the OS ruled the inside: the CPU and memory. But a computer must also talk to outside devices. Keyboards, mice, screens, disks, printers, even a gadget bought yesterday that didn't exist when the OS was made. Each device speaks differently, so how does it understand them all?

01

The world has far too many devices

There's no end to the devices you can attach to a computer.
Keyboards, mice, screens, disks, printers, cameras...
and new ones keep pouring out every year.
Each device sends and receives different signals.
The OS can't possibly memorize them all, can it?

OS

Tap the devices. Each speaks in different signals, hard for the OS alone to understand.

With each device speaking differently, it feels hopeless.
But you can't rewrite the OS to fit each single device,
since new ones keep appearing.
So you place someone between the two: a translator.

02

The driver is a translator

The OS uses just one standard language.
Simple requests like 'read', 'write', 'open'.
The driver that comes with each device translates them.
It turns the OS's 'read' into signals only that device knows,
and turns the device's reply back into the standard language.

readtranslate

Send the standard command 'read'. The driver translates it into each device's signals.

The OS only ever speaks the same standard language.
The driver shoulders all the device's fussy details.
So what about a device the OS has never seen,
a brand-new one? How can it be used?

03

New device? Just install its driver

The OS talks only to drivers, not to devices.
So even when a never-seen device arrives, the trick is simple.
Just install that device's driver, its own translator.
Without changing the OS itself at all,
the driver bridges them, and it works right away.

OSNew device?
no comm

Connect a new device. At first it can't communicate; install the driver and it works.

With one driver, even a new device is taken in easily.
Now they can communicate, but one thing remains.
Devices are usually much slower than the CPU.
How should the OS wait on such a slow device?

04

Don't keep asking; let it tap your shoulder

If the OS stands by a slow device asking 'done yet? done yet?'
and waits, the fast CPU sits idle all that while.
That's a waste. So it just makes the request and does other work.
When the device finishes, it taps the shoulder with an interrupt.
'Done!' Only then does the OS come back to handle it.

CPU

Compare the two ways. Keep-asking leaves the CPU idle; shoulder-tap lets it do other work.

Letting it tap the shoulder keeps the CPU never idle.
Make the request, do other work, and handle the signal when it comes.
This interrupt is the key craft for working with outside devices.
Now, a translator and a shoulder-tap, what do the two add up to?

05

Translator and tap: getting along with the outside

The OS handles the endlessly growing pile of devices with two crafts.
A driver that translates for each device, and an interrupt that signals when it's done.
Thanks to them, even a never-seen device is handled without waste.
Among all those devices, one is especially important: the disk.
It's where files live. How does the OS organize that disk?

OS
DriverKeyboard
DriverDisk
DriverPrinter

Look at the OS in the center. Drivers translate, and a device taps with an interrupt.

In short, the secret to getting along with outside devices is two things.
A translator that carries the words for each device: the driver.
And a shoulder-tap that signals when a slow device is done: the interrupt.
With these two, the OS can join hands with any device in the world.
Next, we'll see how it organizes one such device, the disk, into files and folders.

In one lineThe OS doesn't need to know every device directly. It makes a request in a standard language, and a 'driver' that comes with each device translates that into the device's own signals. So a new device just needs its driver installed to work. And when waiting on a slow device, instead of asking 'done yet?' over and over, the OS lets the device tap its shoulder with an interrupt when finished. Meanwhile the CPU does other work.
Operating systems
Was this helpful? Support seegongsik