12/04/2022, 09:27 Exam/Input Output – COMP3231/COMP9201/COMP3891/COMP9283
Input Output
1. Input Output
1. Describe buffering in the I/O subsystem of an
Copyright By PowCoder代写 加微信 powcoder
operating system. Give reasons why it is required, and give a case where it is an advantage, and a case where it is a disadvantage.
2. Device controllers are generally becoming more complex in the functionality they provide (e.g. think about the difference between implementing a serial port with a flip-flop controlled by the CPU and a multi-gigabit network adapter with the TCP/IP stack on the card itself). What effect might this have on the operating system and system performance?
3. Compare I/O based on polling with interrupt- driven I/O. In what situation would you favour one technique over the other?
4. Explain how the producer-consumer problem is relevant to operating system I/O.
Describe buffering in the I/O subsystem of an operating system. Give reasons why it is required, and give a case where it is an advantage, and a case where it is a disadvantage.
IO buffering is storing IO input into a location in memory. It is required in situations where the unit of transfer is mismatched.
It is advantageous when the peak rate of producing and consuming data is different, since this allows data from IO to accumulate slowly so the user process can process it more efficiently in larger chunks. Generally, this provides a performance benefit because it is faster to copy the data from a kernel to user buffer than it is to transfer in the data from IO.
IO buffering is a disadvantage in fast networking, when copying from the kernel to user buffer takes longer than transferring the data from the device and processing the data. Direct memory access is a better alternative in this situation.
Device controllers are generally becoming more complex in the functionality they provide (e.g. think about the difference between implementing a serial port with a flip- flop controlled by the CPU and a multi-gigabit network adapter with the TCP/IP stack on the card itself). What effect might this have on the operating system and system performance?
https://wiki.cse.unsw.edu.au/cs3231cgi/Exam/Input Output
12/04/2022, 09:27 Exam/Input Output – COMP3231/COMP9201/COMP3891/COMP9283
The increased complexity of the functionality device controllers provide and their improved performance allows for the offloading of IO processing from the CPU to the IO device. This therefore improves the performance of the system and the OS.
Compare I/O based on polling with interrupt-driven I/O. In what situation would you favour one technique over the other?
Polling: CPU repeatedly checks interrupt status register bits until they indicate that the IO operation is complete. This is better if the IO operation is likely to complete faster than a context switch, such as in fast networks.
Interrupt-driven: IO device interrupts CPU when IO operation is complete. This is better if the IO operation is likely to take longer than a context switch. This is the case for most IO operations, such as reading a block from a disk.
Interrupt handling involves switching to kernel mode, preserving the user-level context and eventually returning. This takes much longer than a single poll of an IO status register. If the cost of interrupt handling is bigger than the time spent busy-waiting in polling then polling is faster. 1 poll is cheaper than 1 interrupt; but you only need to handle an interrupt once whereas polling may result in thousands of wasted CPU cycles. Interrupt driven I/O is preferred when you expect the operation to take longer than a context switch. Polling is favourable when the time spent busy waiting is less than the time spent context switching.
Explain how the producer-consumer problem is relevant to operating system I/O.
Many I/O devices utilise a buffer to store incoming information. Upon an event, such as entering the ‘new line’ character, it notifies the OS / user program. Data is then copied from the buffer to a location which it can be used, and the consumed data is cleared from the buffer.
This is an example of a bounded-buffer producer-consumer problem, where the producer is the I/O device, the consumer is the OS / user program and the buffer is bounded by its size. Therefore, concurrency control must be implemented to ensure that race conditions do not occur. Additionally, the OS / program must consume the buffer quickly enough to prevent it from overflowing and lose information.
Exam/Input Output (last edited 2020-08-19 15:33:23 by KevinElphinstone)
https://wiki.cse.unsw.edu.au/cs3231cgi/Exam/Input Output
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com