Interrupts: Exactly What They Sound Like

By Scott Hamilton

Last week was a strange week for me. It was what I would like to call a week of interruptions. Every time I started to do something, a more important matter would pop up and change my plans. I’m sure everyone reading can relate. You might wonder, “What does this have to do with technology?” Don’t worry; I am getting there. I was reminded of how our computers operate. They are in a constant state of interruption.

Modern computers have multiple processors; you can think of these as the brains of the computer. They are usually sitting around waiting for instructions on what they need to do next. Software is the layer of the computer that we interact with, but under the hood, they are a bunch of switches and logic comparison gates, waiting for input so they can produce an output. The way these multi-processor systems work as a single unit is through a process called interrupts.

Each processor in a system goes through a cycle of checking an instruction stack for code that it needs to run, then checking an interrupt queue to see if it is required to change tasks, and then back to running instructions from the instruction stack. You can think of these stacks like a magic paper bin. You place a paper in the top of the bin and the computer processes the paper in the bottom of the bin first. This is a first-in, first-out processing queue, which is the way most computer instructions are processed.

The interrupt queue is a secondary bin of instructions that take priority over the main instruction bin, like your boss walking in and saying, “Stop whatever you are doing and come with me; we have a spill to clean up in aisle 12.”

The interrupt queue is used by computers for priority tasks; for example, the computer is constantly busy updating your screen display. Even if nothing changes it refreshes the screen 60 times a second.

When you hit a key on the keyboard it generates an interrupt. The interrupt gets placed on an interrupt queue and processed on the next clock cycle of one of the processors in your computer. The interrupt queue has to remain processing in the first-in, first-out order or you would type smile and get elmis displayed on the screen. Each character you type might get sent to the display by a different processor, so interrupts are handled centrally, unlike the instruction stacks which can be different for each processor in a system.

Handling interrupts in a computer is a lot like having to handle interruptions in life. There are certain interruptions that have to take priority. For example, if you are on the phone with a friend and suddenly have a grease fire on your stove, it’s fairly safe to say you will probably drop the phone and grab a fire extinguisher. The fire is the higher priority interrupt. Computers have several interrupt queues split up by priority and peripheral device. Very high priority interrupts, like ones coming in from temperature sensors to prevent processor overheat, have a much higher priority and are actually processing in last-in, first-out order, as the most recent interrupt is much more important than the previous ones.

As you can tell, this system gets complex with just a few processors and a few devices. The interrupt handling code is the core layer of any computer operating system, and also the most complex. This system is increasing in complexity every day as our computers get larger and larger. The largest systems on the market today have 1024 processors, and over 300 external connections that can generate interrupts. Some of these devices have multiple interrupt queues themselves, like network cards that can create interrupts in up to 60 queues simultaneously to allow for multiple streams of network traffic entering a system. So the next time you feel like life is full of interruptions, think of the computer sitting on your desk which is getting interrupts from thousands of directions, and be thankful you are dealing with only a few.

Be safe and learn something new this week. If you would like to share what you have learned, e-mail me at 3k*****@gm***.com .

Share via
Copy link
Powered by Social Snap