How Many Computers …

… are in the computer you are looking at right now?

Of course there’s the main one. It’s probably something from Intel or AMD.

But even if you’re still using what would now be considered a dinosaur because it’s so old, it still has several more computers, embedded computers to be precise, inside.

Embedded computers are what I do. I program them. And I teach others how to program them. I will soon be at Lockheed Martin — the building has a cartoon skunk on the outside — to teach some of their engineers how to program embedded computers to … well, I don’t know what they’re gonna do with them. They won’t tell me.

That’s true of a lot of my customers.

But what about that computer in front of you right now. How many embedded computers does it have inside?

First, let me add that Microsoft doesn’t program these embedded computers. Microsoft writes the “Operating System” that runs on the main computer but the embedded ones either don’t have any operating system, or as in the case of avionics — electronics involved in flight instrumentation and controls — they may have a very special kind of operating system, a “real-time operating system” or simply RTOS. The company I work for makes one of those. And the companies I’ve worked for through nearly four decades have made and used different RTOSes.

An RTOS is very different. First, it is extremely reliable. You don’t want the pilot of your fly-by-wire Airbus A320 typing Ctrl-Alt-Del to reboot the computer on the other end of those wires while you’re cruising at 39,000 feet.

Secondly, the RTOS is very predictable. If the pilot tilts the gizmo he uses to fly the plane a little to the left, he expects the airplane will do the same thing it did yesterday with that same amount of motion. And, very importantly, it will do so just as quickly, or just as slowly, as yesterday.

Those two qualities, reliability and predictability, are the hallmarks of the “real-time” operating systems. You know what they will do, when they will do it, and they will do it every time.

So, what about that computer in front of you?

Which parts need to be reliable and predictable?

First, there’s the keyboard. You expect that what you type will be what shows up on the screen. When you press the “g” key you’ll get a “g” on the screen. And you expect that if you type “great”, you’ll see that on the screen — in other words, you expect the keystrokes will show up in the correct order.

Reliable — every keystroke works, it doesn’t miss any — and predictable — “g” always produces “g”.

So, yes, the keyboard has an embedded computer inside. Although it is not apparent from the outside, the keyboard’s embedded computer sends out a number, a “key code” or key#, to the main computer whenever you press down a key, and it sends out a different number when you let that key up. That’s how it can tell when you have pressed, and are holding down, Control and Alt and Delete, all at the same time.

Now, a real simple embedded computer such as the one in your keyboard may not need an RTOS. It only has to do two things at once, 1) scan the keyboard to see if you’ve pushed down a new key or released one that was already down, and 2) start sending that key# to the main computer in your PC. Sending that key#, however, takes time and while it is doing so, the keyboard computer still has to watch what you are doing — you might be, temporarily mind you, typing faster than the keyboard can send those numbers.

When that happens, the keyboard has to “multi-task”, do two things at once (apparently). It has to send the key# for the previous keystroke while, at the same time, scanning to see if you type another key.

Most computers and especially those used for low-cost embedded purposes — a cheap keyboard is less than $20, and that includes the embedded computer inside — only do one thing at a time, but they can do it very quickly. So instead of doing two things at once, the embedded computer “polls” one thing and then it “polls” another. It “polls” to see if you’ve pressed a new key (or released one) and, if you have, it jots down the key# somewhere.

Then, the embedded computer “polls” the communication to the main computer to see if it is time to start sending the next key# (that it jotted down previously). If the embedded computer can go back and forth between those two activities fast enough, you and I will think it’s doing both at once. It will appear to multi-task.

But “polling” like that only works for a small number of activities. When the embedded computer has more than two or three things going on at once, the overhead of that “polling” becomes too much and the performance becomes awful.

That’s when the RTOSes become useful, when lots of things need to be done all (apparently) at the same time.

But I’m getting ahead of myself. The keyboard doesn’t need an RTOS.

Let’s go back inside your computer again and look at another embedded one there.

Another embedded one is the one that’s drawing rectangles on your screen. You call these rectangles, “windows”.

On my computer screen right now I see the web browser. It has a “window” on the screen. That “window” is rectangular in shape, has a tan border and, at the moment, a light blue background on which I’m typing this text.

Each “window” on your screen is drawn by the graphics processor. When you are looking at a web page, the “window” is typically filled with text and graphics, as drawn by the graphics processor. When you “grab” or click the scroll bar and move it, all of the contents of that “window” scroll up or down. Again, that’s done by the embedded computer — or embedded graphics processor — in your computer’s video circuitry.

You’ll hear it called the video chip, the video card, the graphics chip, and so on. If you’re into gaming, live action and video editing, it can be one of the most expensive parts of the computer.

That chip, that embedded graphics processor, is receiving commands from the main processor — the Pentium, the 486, the Itanium, whatever — and doing what it is commanded to do. Those commands are things like, “draw a rectangle starting at location X,Y of size W,H and make the border N pixels wide and TAN, and fill the field with LT BLUE.” To carry out that command from the main computer, the embedded video chip (graphics processor) goes to each of the hundreds or thousands of pixels in the affected area and sets them, one by one, to the correct color. Meanwhile, the main processor in your computer is busy looking at the key#s coming in from the keyboard so that when you type that “g” and the main processor gets it, the main processor can fire off a command to the graphics processor to “Put a ‘g’ in the Times New Roman font at location X,Y on the screen in 12 point bold font.”

(I’m simplifying this a bit but I think you’ll get the idea.)

For a moderately priced graphics card, that embedded graphics engine may be able to concurrently handle several such commands at the same time. One option would be to build a smarter video chip and let it do those things at the same time in the hardware. But that’s expensive. If you only need a moderate amount of video performance, then an RTOS might be a more cost effective solution.

An RTOS would allow the engineers building that graphics processor to create several “tasks” and as the main processor sends commands to draw things on the screen, the RTOS would give each of those commands to a different “task”. The RTOS would then decide, microsecond by microsecond, which task actually gets to do something, and the RTOS would then switch between those tasks really fast so that, to you, it appears that everything is happening at the same time.

By the way, the high-end graphics chips use both additional hardware to perform several commands in true concurrent execution, and also an RTOS to “schedule” commands into those multiple sub-processors of the graphics processor chip. But we’re talkin’ big bucks then.

So, the RTOS is used when the embedded processor needs to do lots of things, all apparently at once, but we don’t want to spend all the money it would take to do all that work, concurrently, in hardware.

A moderately powered graphics chip is a likely place to find an RTOS. It provides a mid-point capability between low-cost, low-performance and high-cost, high-performance. Like baby bear’s porridge, it’s neither too hot nor too cold.

Your disk drive is another place to find an embedded processor. A disk drive, very much like the graphics chip, is getting multiple requests from the main processor to “read this sector and put it here in memory” and to “write that data into that sector on the disk” and “let me know when each of those is done.”

In the course of carrying out those commands, the disk drive is also figuring out what to do about bad spots on the disk.

Yeah, “bad-stuff happens” is true for the disk as in real life. And when it happens on the disk, the software in the disk controller automatically re-maps the bad area to a new, unused part of the disk, remembers this mapping and, from then on, plays like nothing happened.

You get the good data.

So again, in the disk controller, several things are (apparently) happening at the same time and, again, that’s a good situation to use an RTOS.

There’s at least one more embedded processor in your computer. This one is connecting your computer to the internet, either by telephone or more likely, via a 10-base-T connector to an Ethernet network, and through various gizmos called routers and switches and cable modems, each of which use one or more embedded processors themselves, and ultimately it all connects you to the World Wide Web and

So, your computer has a main processor — probably made by Intel or AMD — and at least four embedded processors; there’s one very simple-minded one in the keyboard, another possibly very sophisticated one drawing graphics on your LCD, another in the disk drive and a fourth in your network interface.

And some of those four embedded processors might be using an RTOS to help hold down the overall cost of the system.

So, here’s a final question.

How many embedded processors do you think are in your car?

I asked that question a couple of years ago when I was teaching our RTOS to engineers at Ford and, a couple of weeks later, at General Motors.

Both of them said something to the effect that, if you have one of their low-end cheap and tiny models, the number was probably less than one hundred.


Leave a Reply

Your email address will not be published. Required fields are marked *