Interrupts - How a Computer Works (2015)

How a Computer Works (2015)

7. Interrupts

mb_3d_1s.jpg

np1.jpg

The operating system controls the input and output functions of the computer. Without an operating system every software program would have to write code for controlling the screen, keyboard, hard drive. Instead the operating system does this work for the program. By using a common interface of menus and icons you can more easily learn to use a program, without having to learn a new interface each time. Menus are in the same place and Windows look the same.

BIOS

mb_sm_PT1.jpg

The operating system affects every data transaction on the computer. For instance it manages the type of file that can be written and the way data is sent to a printer or the way a web page is downloaded from the internet. The BIOS and device drivers interface with the operating system. Drivers interpret commands from the o.s and BIOS into instructions for peripherals like a printer or scanner. With every peripheral a specific driver is required which interfaces it to the operating system. The driver enables it to communicate with the o.s.


I/O Controller

mb_sm_io.jpg

When a peripheral communicates with the computer it generates a special signal known as an interrupt. An interrupt is generated every time you press a key on the keyboard or move the mouse. This signal goes to the I/O controller hub chip (ICH2).

The controller chip tells the CPU it needs to transfer data to it. The CPU in turn puts the address of the currently running program into RAM. The portion of RAM this address is stored in is called the stack.

Keyboard Interrupt

mouse_mat2.jpg

Mouse: IRQ 12

Each peripheral has an interrupt number associated with it. The IRQ number is unique to each peripheral. The CPU retrieves this number and looks in the interrupt table which is stored in RAM to find the memory address associated with a particular interrupt. The CPU reads in the instructions it found at the beginning of the address. The memory address is in the range where the BIOS was copied to during the POST test. The code is executed, if a key was pressed, code which represents the key would be sent to the program that currently has the pointers focus.

The next action is to display the character from the key on the screen. If the code instruction is completed properly the BIOS issues an IRET command, which tells the CPU to get the address of the stack in RAM, so it continues with what it was doing before the interrupt.