Computer System Structure and Components
Computer System Structure and Components
CPU
Memory controller
Disk controller
Printer controller
3. I/O Structure
Programmed I/O 1) Application program (process) calls an I/O system call and waits for the I/O to complete. 2) I/O system call routine calls the corresponding I/O function of the device driver. 3) Device driver fills the registers of the device controller and signal start 4) The device controller starts the I/O and CPU checks the flag register of the device controller periodically (polling overhead). 5) After each unit I/O, the device controller sets the flag in its register. 6) CPU finds the flag and moves the data to/from the main memory from/to the controllers buffer. 7) Repeat from 2, 3, or 4)1 to 6) until all data is transferred to/from the device.
Interrupt-driven I/O 1) Application program (process) calls an I/O system call and waits for the I/O completion. 2) I/O system call routine calls the corresponding I/O function of the device driver. 3) Device driver fills the registers of the device controller and signal start 4) The device controller starts the I/O and CPU is free from the polling. 5) After each unit I/O, the device controller generates an interrupt signal. 6) CPU stops current process and moves the data to/from main memory from/to the controllers buffer. 7) Repeat from 2, 3, or 4) to 6) until all data are transferred to/from the device. CPU is free from the polling. Thus, CPU can process another job while the device is working on 4) and 5). However, in a high-speed device, such as disk, step 4) is fast and frequently interrupts the CPU. As a result, the CPU must switch to the interrupt routines very frequently to move the data in the controller buffer to main memory (switching overhead). Good for byte (or word)-based slower devices (e.g., keyboard, serial port)
Direct Memory Access (DMA) 1) Application program (process) calls an I/O system call and waits for the I/O completion. 2) I/O system call routine calls the corresponding I/O function of the device driver with a destination (main memory location). 3) Device driver fills the registers in the device controller and signal start 4) The device controller starts the I/O and the CPU is free from the polling.
Depends on the OS, device, device driver, and the device controller.
5) After each unit I/O, the device controller (or DMA controller) moves the data to/from the main memory from/to the controllers buffer. 6) Repeat from 2, 3, or 4) and 5) until all data are transferred to/from the device. 7) Device controller generates an interrupt signal. Since the device controller accesses main memory frequently, CPU processes other jobs at a slower speed. Good for block-based fast I/O devices (e.g., disk and tape, usually block size is 512, 1K, 2K, or 4K bytes).
Memory-Mapped I/O Ranges of main memory addresses are directly mapped to separate device registers. So, I/O is main memory access. To perform I/O, CPU reads or writes data in these specific memory locations. After the read/write, the data keep flow through the system bus and duplicated in the device controllers registers. Then, device performs I/O and the data transferred to the controllers registers are also duplicated in the main memory. Additional memory overhead. Good for very fast byte (word)-based devices (e.g., video display)
4. Storage Structure
Read/Write through Capacity Registers Internal Cache External Cache Main memory Electronic Disk (e.g., Flash cards) Magnetic Disk (e.g., Hard disk) Optical Disk (e.g., CD-ROM) . . . Figure 3 Storage-device hierarchy Coherency and Consistency problem: multiple copies of data (see Read/Write through on Figure 3) The problem is more complex in tightly-coupled systems Access speed
5. Hardware Protection
Example 1. An application program is trying to write on OS kernel code in main memory. Example 2. An application program is trying to write on another program in main memory. Example 3. An application runs infinite loop and hold CPU time infinitely. Example 4. An application program prints indefinitely long data repeatedly.
Solution: Modern computer systems attack this problem by using dual-mode operation. In dual-mode systems, only OS can access I/O devices, memory, and CPU in its monitor mode. Users process will never be allowed to directly access system resources. Application programs access these resources through system calls indirectly (c.f., OS needs hardware mode bit for this solution: 8088 does not have it, after 80486 supports this bit and, as a result, Windows/NT and OS/2 support dual mode operation).
OS may needs CPU timer and two additional memory registers (base and limit)