Consider if you write VERY BAD .. and you write the operating system.
This operating system also uses a keyboard.
So, you ask your OS to go and get some input from the keyboard, but no keys are pressed, and there are no keys in the buffer. your whole OS will HAGE DEAD until it receives keyboard input.
Compare this to looking ahead, you ask if the KB has any characters before making a call. You get a NO answer, so your OS then goes and does something else.
That's why you should take care, now if you then multiply this with all the other potentially blocking tasks, you can understand why looking ahead is crucial.
Because this also applies to OUTPUT: memory on the drive interface can also drop data on the drive faster than it can handle. if you do not know that the drive buffer is flooded with data, then the task will be blocked until the buffer can receive more data.
It also emphasizes the nonsense of "very few useful uses."
bob Sep 15 '13 at 4:10 2013-09-15 04:10
source share