CSE1CT Computer Technology

System Resources


There are four types of System Resources:

screenshot of Windoze Device manager window showing Direct Memory Access (DMA), Input/Output (I/O), Interrupt Request (IRQ) and Memory selections

Interrupts

The CPU can only work on one task at a time. In a multitasking operating system the CPU appears to perform multiple tasks simultaneously by quickly switching between them. The Operating System shares CPU time between the programs it is running and the peripheral devices that demand attention.

The alternative to interrupts (called polling) is to have a program in the OS that periodically checks each of the peripheral devices that might require attention. This approach is inefficient as the CPU would be wasting time checking devices that usually did not require attention.

Hardware Interrupts are sent to the CPU over the control bus to indicate that a peripheral device requires attention.

Software Interrupts are special programming instructions used by the Operating System to notify the CPU that a program requires data to be fetched or delivered to a peripheral device. Software Interrupt routines are provided by the OS for performing basic i/o operations in conjunction with the BIOS.

Hardware Interrupts are delivered to the CPU through two interrupt input lines:

NMI - The Non Maskable Interrupt

A Non Maskable Interrupt cannot be ignored by the CPU.

IRQ - The Interrupt ReQuest

The IRQ input is "maskable". The CPU can choose to ignore it until it is convenient to handle the interrupt.

The CPU has a single IRQ input but there are many devices demanding the CPU's attention. Two Programmable Interrupt Controllers (PICs) are used to prioritorise and direct all maskable interrupts to the one IRQ input on the CPU. The PICs are integrated into the "chipset" in modern computers.


The PICs have the job of delivering the interrupts to the CPU in "priority order" (the lowest numbered input has the highest priority.

The original PC had only one PIC and IRQ 2, 3, 4, 5, 6 and 7 were connected to the 8 bit ISA bus.

               ______________
              |              |
  IRQ 0 ------| highest      |
  IRQ 1 ------|   priority   |
  IRQ 2 ------|              |
  IRQ 3 ------|              |
  IRQ 4 ------|    PIC       |------------> to CPU
  IRQ 5 ------|              |  (one output)
  IRQ 6 ------|              |
  IRQ 7 ------|  lowest      |
              |   priority   |
              |______________|

With the introduction of the 16 bit ISA bus the number of IRQs was increased to 16. A second PIC was added and to maintain compatibility with the original PC, the PICs were cascaded using IRQ 2. IRQ9 was substituted for IRQ2. IRQs 10, 11, 12, 14 and 15 were carried by the 16 bit ISA extension.

Diagram. Cascaded PICs. The first PIC handles interrupts 0, 1, 3, 4, 5, 6 and 7. The second PIC handles interrupts 8 through to 15. End of Diagram

ISA bus devices usually required manual configuration to set the interrupt number and other resources for each expansion card. This was done using dip switches or (later) software.

Automatic assignment of system resources to avoid conflicts is done using "Plug and Play" where devices negotiate with the operating system for their prefered values.

With the disappearance of the ISA bus, and the universal use of the PCI bus (and Plug and Play), the "8 and 16 bit" interrupts are available for any device.


How interrupts are handled

Note:
  1. It is entirely possible for an interrupt to be interrupted by a more important interrupt. in fact, the more time sensitive hardware is allocated the lowest interrupt numbers so that the CPU gives it the best service.
  2. It is possible for multiple devices on the PCI bus to share the one interrupt. The interrupt service routine has to be aware of this. It has to "ask" each of the possible interrupting devices if it caused the interrupt.
  3. Interrupts on the older ISA bus weren't normally shared, though there is no hardware reason why this couldn't be done.

Software Interrupts

The CPU can generate Software Interrupts through the use of special instructions. These are handled in a similar way to hardware Interrupt Requests, except that the PICs are not involved. Software Interrupts are often used to communicate between a user program and the operating system.


Input and Output Ports

These are addressable locations used by the CPU to communicate with input/output devices. The IO ports act much like memory locations (but in an entirely different "address space") - they can be read and written by the CPU. There are subtle differences though.


DMA channels

Direct Memory Access (DMA) channels are used by high-speed communications devices which require high-speed data transfers. Examples of such devices include are sound cards and drive controllers.

In a DMA transfer, the CPU is not directly involved. When a DMA peripheral wishes to transfer data to or from memory, it issues a DMA request signal to a DMA controller. The DMA controller then takes control of the system bus and moves a block of data between the peripheral and main memory without the need for CPU intervention. Providing that CPU does not require the system bus during this time the CPU may continue to process its current task, thus increasing system performance.

Diagram. The DMA controller commands I/O to read and memory to write. data travells from I/O directly to memory. The CPU is not involved. End of Diagram

The "non DMA" way of performing input and output required the CPU to handle the data twice. In the example (performing input), the CPU first read the I/O device then wrote the data to memory.

Diagram. Data first travells from I/O to the CPU. On a second bus cycle, data travells from the CPU to the memory. End of Diagram

The original 8-bit ISA bus had four DMA channels allowing for high-speed transfers between devices and memory. Only three of these channels were made available to the expansion slots. Of these three two were typically used for the hard disk controller and the floppy disk controller, leaving one for use by an additional device.

Since the introduction of the 80286, the ISA bus has supported eight DMA channels (DMA 0 ... DMA 7), seven of which are available to the expansion slots. Like the additional IRQ lines, DMA channels were added by cascading a second DMA controller from the first. As a result, DMA channel 4 is used to cascade channels 0 to 3 to the CPU. Channels 0 to 3 are available for 8-bit transfers (can be used with both 8 and 16 bit ISA cards) and channels 5 to 7 are capable of 16-bit transfers only.


Memory Addresses (Memory Mapped I/O)

One final method of communicating with a device is the idea of mapping the I/O ports of a device into the normal memory space of the CPU. This allows for the CPU to read from or write to an area of "memory", having the device receive or provide the data. This method can be extremely fast due to the fact that memory bus speeds are typically higher than those of the expansion buses (ISA, PCI, etc.) The most recent example of memory-mapped I/O is the Advanced Graphics Port (AGP.) Unfortunately, there are a number of complexities that need to be overcome when using memory mapped I/O.


Hardware Conflicts

When two or more devices attempt to use the same resource (eg. the same IRQ line or I/O Port) ambiguity can occur with unexpected and disastrous results.

Hardware resource conflicts should be avoided.

It is possible for devices to share IRQ lines, however the ISR must determine which device generated the interrupt. Only one of the two devices may be used at any time, otherwise a IRQ conflict will occur.

Memory conflicts are resolved by ensuring that each device uses a different base address and that the area of reserved memory for the device does not extend into another device's memory area.

I/O port address conflicts are resolved in a similar way to memory conflicts. Each device requires a range of port addresses. I/O ports are used to communicate commands and data to/from hardware devices. If two devices attempt to use the same port both devices will receive and provide data when the port is read from or written to.

Like IRQs, DMA channels may also be shared between devices, providing only one device operates at a time. However, if both devices need to operate at simultaneously, separate DMA channels must be used.


Resource Allocation

There are effectively two types of resource allocation, manual or "Plug and Play". Manual allocation requires that any I/O ports, IRQ lines, DMA channels or Memory Mapped I/O be setup by the user, either by the use of external jumpers (switches) or by the use of a software configuration utility. This is normally the case with all ISA expansion cards.

"Plug and Play" allows for the resources to be automatically distributed by the system BIOS, working together with the Operating System. As a result, no resource conflicts should occur and each device should work in harmony with the rest.


Bootup

Introduction

When a PC is first switched on, the Operating System (OS) is not in memory, the hardware to fetch the OS usually is not ready and the memory manager has not been initialised so most of the RAM cannot be used.

The CPU is held in a RESET state until the computer's power supply is working properly. This typically takes about half a second from "switch on". Formally, the power supply circuit sends a Power_Good signal to the "reset" circuitry, bringing the CPU out of the reset state

At this point, the CPU wakes up in Real Mode ie. it is thinking like an original 8086 with one megabyte of segmented memory.
The memory manager has not yet been initialised, so the CPU has no choice.

The CPU goes to a "well known" address in memory - FFFF:0000 hex - to fetch the first instruction.
This means that permanent memory (typically Flash memory) must be located at this address to ensure there really is some code there.

FFFF:0000 hex is exactly 16 bytes back from the 1MB boundary. Since 16 bytes is not enough room to store the code necessary to start the system, a JMP instruction is usually used to move back to a block of code located within the first 1MB of memory.


The Boot Process

  1. A basic system test, the first part of the Power On Self Test (POST) is now performed, ensuring that critical system components exist and are functioning correctly. Any errors found are indicated via 'beep' codes as the video adapter is not yet initialised nor operational.
  2. The first 16 entries in the Interrupt Vector Table (IVT) are filled with pointers to Interrupt Service Routines (ISRs) located within the BIOS ROM. Maskable interrupts are then enabled, allowing for the use of interrupt driven devices, in particular the keyboard.
  3. The BIOS now performs a scan of memory locations C000:0000h through to C780:0000h, in an attempt to locate the video adapter ROM BIOS code, either located on a video card or integrated into the motherboard. If a video BIOS is located it is checked for integrity and then executed. If no video adapter ROM is found, the motherboard ROM video drivers are used to initialise the video display hardware.
  4. The BIOS now scans memory locations C800:0000h through to DF80:0000 in 2KB increments looking for any other ROMS located on other hardware devices such as SCSI adapters, etc. If any are located they are integrity tested and then executed.
  5. The BIOS checks the word value at memory location 0000:0472h to see if this is a cold start or warm start. A value of 1234h indicates a warm start (ie. we have already been up and running.) Any other value suggests a cold start. A warm start will bypass memory tests and the like.
  6. The Power On Self Test is now completed. Any errors found during the POST are now reported using a combination of on screen error messages and audible beeps.
  7. The system BIOS will then check to see if devices listed in the configuration data exist and are functioning correctly. Devices such as serial and parallel ports are configured and assigned identities. Typically brief messages will be displayed giving running summary of the setup process.
  8. If Plug and Play (PnP) is supported by the BIOS, any detected PnP capable devices are configured. A summary of all PnP devices is usually shown giving a list of devices and the resources allocated to each.
  9. A summary screen is now typically displayed, giving information such as the CPU installed, the amount of memory present, the number and type of disk drives in the machine and so on. At this point the system and its associated devices are ready to run.
  10. The BIOS now attempts to locate and load the boot sector of the installed operating system. This involves checking each boot device, in order, reading the first sector from the beginning of the device and placing it into memory. The last two bytes of the sector are checked for the boot signature (55AAh.) If not a Software Interrupt 18h is generated causing an error message along the lines of 'Non-System Disk or Disk Error'.
  11. If the boot loader for the operating system has been successfully located and loaded, control of the machine is then transferred to the operating system.

Warm Boot vs Cold Boot

The boot sequence used when a PC is first powered on (after being completely powered off) is known as a cold boot. This causes all system checks to be performed. When a machine is rebooted, either by pressing the reset switch, telling the operating system to reboot the machine or by pressing CTRL+ALT+DEL a warm boot is performed. In this case less time is spent testing system components as it is assumed that the system has already been running, the full POST has previously been performed and the hardware is already functional.


Valid XHTML 1.0 Transitional