What does the term block mean wrt computer science? I have seen it being used in multiple occassions but never understood what it means. Like blocking I/O? Googling doesn't seem to help me much.
feedback
|
|
Blocking I/O means that the program essentially asks, "Get me this data, I'll wait until its ready". This is in contrast to non-blocking I/O. There are two flavors: "Get me this data, I'm going to go do something else. Interrupt me when the data is ready.", and "Get me this data, I'm going to go do something else. I'll ask you later if you have it yet." It's important because if a program blocks while waiting for data, it can't do things like respond to mouse clicks or repaint the screen. This is what's happening when you see a program labeled as "Not Responding" in the task manager. | ||||
feedback
|
|
In summary it means that the process hangs (waits) until the I/O completes. This Wikipedia article covers it in passing, focussing on non-blocking I/O:
Of course, non-blocking I/O doesn't help much if the next step is to do something with that data. | |||
|
feedback
|
|
Blocking is the simpler, move obvious way:
You can't do a two-liner with non-blocking, since it involves setting up objects for each connection, which are then fed by a single "multiplexor" that constantly looks for the next thing that comes in. Imagine how the two approaches are different with a thousand or a million connections. You choose one or the other because of factors like:
For example, you might have a problem with blocking I/O holding several thousand connections open, one with each thread, because your system doesn't like having several thousand threads. But it turns out to be fairly complex issue. Read about how the perception has flip-flopped with Java, including the linked slide show (PDF). | |||
|
feedback
|
|
In addition to indicating a form of synchronous signalling, in a programming context 'block' can also mean a section of code grouped together. | |||
|
feedback
|