How can I get input from PVM messages and e.g. X?

next up previous contents
Next: I'm not getting Up: Advanced programming Previous: Advanced programming

How can I get input from PVM messages and e.g. X?

It is possible for a PVM task to get input from PVM and other sources at the ``same time'', and there are at least two common ways to do it.

The simplest is to poll each input in turn, and handle any that having data pending. For example, you might use pvm_probe() to check for messages and XCheckWindowEvent() to check for X events. The obvious disadvantage is that spin-waiting wastes CPU time. This is less of a problem on dedicated machines than time-shared ones. You can slow down the polling frequency by using pvm_trecv() to introduce a small timeout in the loop.

A more efficient but also more complex solution is to call pvm_getfds() to get list of file descriptors used by libpvm for communication, and then wait on these (and your own) files with select(). This is simple if direct routing is disabled, since only a single socket (to the pvmd) will be in use.

Bob Manchek
Fri Mar 3 15:08:11 EST 1995