Understand the inner workings of a computer system: how do memory, I/O devices, buses, and external memory work together?

  • Memory is the storage space that can be directly accessed by the processor. To speed up memory access, computer systems usually provide some cache, which is usually managed by hardware.
  • I/O devices consist of I/O controllers and physical devices, and the processor manages the physical devices through the I/O controllers.The I/O controllers are mainly composed of control and status registers (CSRs) and data registers. The processor reads CSRs to obtain device status, writes CSRs to control device actions, and reads and writes data registers to exchange data. The kernel usually abstracts I/O devices into a set of registers and gives an I/O address to a register. The processor accesses the I/O registers through the I/O address.
  • Many device registers in modern computer systems can be mapped into the physical address space. At this point, each device register has a physical memory address. This type of I/O is called memory-mapped I/O. It is easy to use but consumes physical memory addresses.
  • The external memory is usually abstracted as an array of data blocks, each with a serial number The processor can read or write any random block of data in the external memory by using the serial number. The operation of the external memory is usually in blocks, so it is also called the external memory as a block device. Correspondingly, other I/O devices are called character devices. In short, block devices read and write data in blocks, such as hard disks, flash memory, etc., while character devices read and write data in characters, such as keyboards, mice, printers, etc.
  • Buses are responsible for connecting processors, memory, and I/O controllers. Commonly used buses are ISA, PCI, PCI-E, AGP, ATA, SCSI, and so on. The bus is also responsible for detecting, enumerating the devices connected to it.