Describe three circumstances under which blocking I/O should be used.Describe three circumstances under which nonblocking I/O should be used.Why not just implement nonblocking I/O and have processes busy-wait until their device is ready ?
Generally,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 key board 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 asynchonous 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.
Generally,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 key board 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 asynchonous 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.