os202

Logo

OS202 - johanessteven19 - Updated Weekly throughout the semester!

View the Project on GitHub johanessteven19/os202

Back to Home


Top 10 List of Week 10

  1. I/O Systems.
    An Operating System needs a ‘tool’ for it to communicate with the user. The OS first will have to know what to do. The user will usually give out commands to the system and the result of that command will be communicated back to the user in some form, whether visible or not. For example, if a user wants to open a certain program on a Windows computer, they can simply use the mouse to point the cursor onto the program shortcut, double-click it, and then the program will open. The OS will take this ‘stimulus’ from the mouse being clicked, process it, and the resulting output will be the selected program being opened. Therefore, to make sure that the OS works smoothly, it is important for the OS to manage its I/O devices by making up entire I/O subsystems, each specific to their own operations.

  2. I/O Hardwares.
    There are several categories that an I/O hardware can be separated into:
    • Storage, such as Hard Disks, USBs, etc.
    • Communications, such as a mouse, keyboards, etc.
    • User-interface
    • Others. These devices are then connected to the machine via ports which will allow communication between the device and the machine, whether through wired or wireless connections.
  3. I/O Buses.
    A bus, in the context of I/O devices, is a common set of wires that is capable of connecting multiple I/O devices at once. The common modern PC will have about 4 different type of buses, which are:
    • PCI Buses, which is able to connect high-speed, high-bandwidth devices into the CPU and the memory subsystem of the PC.
    • Expansion Buses, which is able to connect slower, low-bandwidth devices that can deliver data one character at a time.
    • SCSI (Small Computer System Interface) Buses, which is able to connect multiple SCSI devices into a common SCSI controller.
    • Daisy-chain Buses, which is used to connect multiple devices that are connected to one another. In this case, only one of those devices are directly connected into the host.
  4. Communicating with devices.
    The machine is able to communicate with the connected I/O devices using registers. Each register will be associated to a certain port, and range anywhere from one to four bytes in its size. The register’s role is mainly to store data, which can then be retrieved later on. There are four common types of registers used in this role, which are:
    • Data-in Registers, which will be read by the host to get input from the connected I/O devices.
    • Data-Out Registers, which will be written into by the machine to communicate the output.
    • Status Registers, which will show the status of the device to ascertain whether or not the device is available (in idle / ready for input states), busy, error, etc.
    • Control Registers, which contain bits written by the host to issue certain commands based on the bits.
  5. Interrupts.
    In certain cases, there may be times when multiple inputs are sent at once. In these cases, an interrupt will be needed to prioritize certain inputs that need immediate attention. There are steps in raising an interrupt:
    • The device controller will first raise an interrupt flag by signaling the interrupt request line.
    • The computer’s CPU will then save the current state, and control of the CPU will be transferred to the interrupt handler routine, which is stored at a certain address in memory.
    • The interrupt handler will then determine the cause of the interrupt, perform the necessary processing, load the saved state, and execute a return from interrupt instruction. Control is given back to the CPU.
  6. Direct Memory Access (DMA)
    DMAs are special processors that can handle large data transfers. Instead of wasting CPU registers by sending the large data one byte at a time, the DMA is able to handle this work on the side, while the freed-up CPU registers can handle other works. This is done by:
    • First, the host will send a specific command to the DMA. This command will specify where the data is located, where the data needs to be transferred to, and the size of the data.
    • Second, the DMA will then handle the data transfer by performing handshaking through special wires called the DMA-request and the DMA-acknowledge wires.
    • During the transfer, the CPU will not be able to access the PCI bus, but its internal registers and caches are freed up.
    • After the process is done, the DMA will interrupt the CPU and normality is resumed.
  7. Improving I/O efficiency.
    To improve efficiency, there are methods that can be implemented, such as:
    • I/O scheduling. By putting certain less-important requests into a waiting state and giving out priorities to the more-important processes.
    • Buffering. For slower devices, the data can first be written into a buffer first, before being sent out to the faster device all at once.
    • Caching. A copy of frequently accessed data is stored in a fast-access location, therefore increasing the speed of data retrieval.
    • Spooling and Device Reservation. Data is buffered for devices that cannot handle interleaved data streams. Especially useful in giving out exclusive access to a device for certain processes.
    • Etc.
  8. Polling.
    Polling is used whenever multiple devices are undergoing handshaking, meaning they are exchanging data.
    • First, the host will repeatedly check the busy bit of the device until it is clear.
    • Second, the host will write a byte of data into the data-out register. Control register bit is set to write.
    • Third, the host sets the command register to a ready state.
    • Fourth, the device controller sets the busy bit and proceeds to read the data stored in the data-out register.
    • The data is outputted, while the error bit of the status register, command-ready bit, and the busy bit are cleared.
  9. Memory-mapped I/O
    This is an alternative way for the machine to communicate with the device. Memory-mapped I/O will first map the address space of the processor into the device, which will then be used during communication (reading/writing of data) between those memory areas and the device. This method is more suitable for devices that must move large amount of data as quickly as possible, such as graphic cards, etc.

  10. Synchronous vs Asynchronous I/Os
    A Synchronous I/O means that the CPU execution will wait while there is an I/O process going on. Asynchronous I/O means that the I/O process will happen concurrently with the CPU execution process.