One of the nice things about being a programmer is that you get to work in a simplified world. Computers are designed and built to do exactly what you tell them to do (even if it’s not what you mean), and to do the same thing over and over again, yielding nice, reproducible results. The reason programs are so well behaved is that they normally execute sequentially. One step follows another, and nothing happens in between, so your data will stay the same as it was when you last touched it. Your program’s flow becomes obvious and any bugs that you may have are reproducible.
One of the nice things about being a programmer is that you get to work in a simplified world. Computers are designed and built to do exactly what you tell them to do (even if it’s not what you mean), and to do the same thing over and over again, yielding nice, reproducible results. The reason programs are so well behaved is that they normally execute sequentially. One step follows another, and nothing happens in between, so your data will stay the same as it was when you last touched it. Your program’s flow becomes obvious and any bugs that you may have are reproducible.
Unfortunately, in the real world, most events are unpredictable, data usually comes in randomly, and users generally don’t want to wait for programs to get around to paying attention to their needs. Event-driven programming, used for most GUI development, is one way of handling these situations. Programs block until something interesting happens (say a mouse moving or a key being pressed), handle that action, and go back to waiting for the next thing to happen.
While this method is quite reasonable for programs that don’t have to do much work to handle a single event, it becomes much more difficult when the program has a large amount of work to do, since it constantly needs to interrupt its processing to see if there are other events that require handling. Unix provides a restricted method called signals for dealing with asynchronous events….
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: