next up previous
Next: Helper Functions for Constructing Up: Integrating FUSD With Your Previous: Integrating FUSD With Your

Using fusd_dispatch()

Recall from Section 4.1 that fusd_register returns a file descriptor for every device that is successfully registered. This file descriptor can be used to activate device callbacks ``manually,'' without passing control of the application to fusd_run(). Whenever the file descriptor becomes readable according to select(2), it should be passed to fusd_dispatch(), which in turn will activate callbacks in the same way that fusd_run() does. In other words, an application can:

  1. Save the file descriptors returned by fusd_register();
  2. Add those FUSD file descriptors to an fd_set that is passed to select, along with any other file descriptors that might be interesting to the application; and
  3. Pass every FUSD file descriptor that select indicates is readable to fusd_dispatch.

fusd_dispatch() returns 0 if at least one callback was successfully activated. On error, -1 is returned with errno set appropriately. fusd_dispatch() will never block--if no messages are available from the kernel, it will return -1 with errno set to EAGAIN.


next up previous
Next: Helper Functions for Constructing Up: Integrating FUSD With Your Previous: Integrating FUSD With Your
Jeremy Elson 2003-08-20