السؤال الأول
Polling an I/O device requires that the CPU manually check if the I/O device is ready, this costs the systems cycles. Interrupt driven on the other hand allows the CPU to process as it pleases whilst waiting for the device. When the device finishes it will interrupt the CPU at which stage it can act. Interrupt driven is useful on systems that are performing a multitude of tasks with many different I/O devices. It would be detrimental on such a system to have the CPU wasting cycles waiting on a single I/O device when there are other tasks and I/O devices to schedule. Polling is a cheaper solution and doesn’t require interrupt hardware and it a good solution if the CPU would normally only be sitting idle waiting for an interrupt anyways. An example of which is a washing machine, the CPU has nothing better to do than wait for the I/O on a washing machine, it’s not going to be running some batch tasks in the background.
السؤال الثاني
blocking I/O is appropriate when the process will only be waiting for one specific event. Examples include a disk, tape, or keyboard read by an application program. Non-blocking I/O is useful when I/O may come from more than one source and the order of the I/O arrival is not predetermined. Examples include network daemons listening to more than one network socket, window managers that accept mouse movement as well as keyboard input, and I/O-management programs, such as a copy command that copies data between I/O devices. In the last case, the program could optimize its performance by buffering the input and output and using non-blocking I/O to keep both devices fully occupied.
Non-blocking I/O is more complicated for programmers, because of the asynchronous rendezvous that is needed when an I/O occurs. Also, busy waiting is less efficient than interrupt-driven I/O so the overall system performance would decrease.