Made with ScholarlyMake flashcards like these from your own notes
Question:What is the primary function of an IO device in a computer system?
Answer:An IO device allows a computer to interact with its surroundings, enabling input and output of data. Examples include storage devices, human interface devices, and networking devices.
Question:How does the kernel manage the complexities of different IO devices?
Answer:The kernel provides abstractions of IO systems to hide the complexities of heterogeneous IO devices. This includes uniform naming conventions and mechanisms for data transfer, buffering, and scheduling.
Question:What are the three main types of registers found in IO devices, and what is the purpose of each?
Answer:IO devices typically have three types of registers: Status register (to see the current status), Command register (to notify the device to do a specific task), and Data register (to pass data to the device or get data from the device).
Question:What is programmed IO, and what role does the CPU play in it?
Answer:In programmed IO, the CPU directly writes data to the device's data register and then writes a command to the command register, initiating the device's operation. The CPU remains involved in the data transfer process.
Question:What is polling in the context of IO event completion, and what is its main drawback?
Answer:Polling involves the OS kernel repeatedly checking the device's status register to determine when a task is complete. This method consumes CPU resources as it continually checks the IO status.
Question:How do interrupts differ from polling in handling IO event completion, and what advantage do they offer?
Answer:Interrupts are a mechanism by which the device notifies the CPU upon completion of an IO operation. This allows the CPU to perform other tasks while waiting for the IO operation to finish, avoiding the CPU wastage associated with polling.
Question:What is the role of device controller?
Answer:Device controllers manage data exchange between the CPU and IO devices. They are the hardware endpoint and are essential for the proper functioning of IO operations.
Question:What is the role of device driver?
Answer:Device drivers provide abstracted APIs to hide the tedious operations of IO devices, such as networking stack and storage stack in Linux.
Question:Why might interrupts be better than polling for CPU utilization?
Answer:Interrupts can be better for CPU utilization because the CPU doesn't have to constantly check the device's status. It can perform other tasks and only gets interrupted when the device needs attention, leading to less CPU waste.
Question:When might polling be preferred over interrupts?
Answer:Polling might be preferred when the device is very fast. In such cases, the overhead of setting up and handling interrupts might outweigh the benefits of avoiding constant checks.
Question:What overhead is associated with using interrupts?
Answer:Context switching between processes is required when using interrupts, which introduces overhead.
Question:Describe a scenario where CPU usage is inefficient when writing data to a device.
Answer:When the CPU is responsible for writing data to a device's data register and then writing a command to the command register, it often involves waiting in a loop (STATUS BUSY) until the device finishes the command. This waiting period consumes CPU cycles unnecessarily.
Question:How can CPU usage be improved when writing data to a device?
Answer:Instead of the CPU directly copying or updating memory data to the device, a Direct Memory Access (DMA) controller can be used to handle the data transfer, freeing up the CPU for other tasks.
Question:Why is CPU time wasted when the CPU handles data copying between memory and a device?
Answer:The CPU is inefficiently utilized because it is tied up with the data transfer process, preventing it from executing other computations or tasks. This is especially wasteful when large amounts of data are being moved.
Question:What is Direct Memory Access (DMA)?
Answer:DMA is a technique where a separate processor (DMA controller) is introduced to perform data copying between memory and a device, instead of the CPU. This allows the CPU to perform other tasks concurrently.
Question:Explain the behavior of a DMA controller in data copying.
Answer:The CPU instructs the DMA controller to perform a data copy and then voluntarily yields (context switching). The DMA controller handles the data transfer, and once the I/O task is complete, it generates an interrupt to inform the CPU.
Question:Outline the steps involved in reading data from a disk using DMA.
Answer:1. CPU initializes the DMA controller. 2. CPU tells the DMA controller the address and size of the buffer. 3. DMA controller requests data from the disk controller. 4. Disk controller transfers data to the DMA controller. 5. DMA controller writes the data to the buffer address and decrements the remaining byte count. 6. Steps 3-5 repeat until all data is transferred, and then the DMA controller generates an interrupt to the CPU.
Question:Why do CPU and DMA controllers need to know the locations of I/O device registers?
Answer:To interact with I/O devices, the CPU and DMA controllers need to know the specific memory addresses where the device's registers are located, allowing them to send commands and receive data.
Question:How does the system differentiate between memory addresses for main memory and I/O devices?
Answer:I/O devices have their own address space separate from main memory. The system needs a way to distinguish between the two, which can be achieved through specialized I/O instructions or memory mapping techniques.
Question:Explain the use of specialized I/O instructions.
Answer:Specialized I/O instructions are CPU instructions specifically designed for accessing I/O devices. These instructions allow the CPU to interact with the device's registers using their designated I/O addresses.
Question:What is the key characteristic of memory-mapped IO?
Answer:Some regions of physical memory address are allocated and reserved for IO devices. The mapping is managed by the page table.
Question:How can we distinguish between memory and IO devices in memory-mapped IO?
Answer:By the physical address value itself.
Question:What are the main roles of a device driver?
Answer:Initialize the device, manage IO operations, handle events between the kernel and the device (e.g., logging), and control the IO behavior between devices and higher layers.
Question:Where does the device driver operate?
Answer:As a part of the kernel.
Question:Who typically writes the device driver?
Answer:The device manufacturer.
Question:What is the main function of the IO stack?
Answer:To manage the flow of data and control between user applications and hardware devices.
Question:List the layers typically found in the IO stack.
Answer:User processes, Kernel, Device Drivers, Hardware.
Question:Give examples of the application layer mechanisms frequently used in networking.
Answer:Sockets, System Call Interface.
Question:Give examples of the kernel layer mechanisms frequently used in networking.
Answer:Mem Alloc, Sockets, Hash Tables, proto_ops, Synch, Atomic Ops, Wait Queues, Soft IRQs, Lists, Notifiers, Interrupts, DMA, PCI, Timers
Question:List some key data structures used in networking within the kernel.
Answer:sk_buff
Question:What are the main characteristics of IO device addresses compared to main memory addresses?
Answer:The address provided is for IO devices, not for main memory. IO instructions are needed and are a kind of privileged instructions. It involves a more complex architecture. OS needs to manage different address spaces for memory and IO devices. Processor needs to support privileged instructions for IO devices