The client's view
We've already seen a hint of what the client expects. It expects a file-descriptor-based interface, using standard POSIX functions.
The resource manager's view
Let's look at things from the resource manager's perspective. Basically, the resource manager needs to tell the process manager that it'll be responsible for a certain part of the pathname space (it needs to register itself). Then, the resource manager needs to receive messages from clients and handle them. Obviously, things aren't quite that simple.
The resource manager library
Before we get too far into all the issues surrounding resource managers, we have to get acquainted with the QNX Neutrino resource manager library. Note that this library actually consists of several distinct pieces:
Writing a resource manager
Now that we've introduced the basics—how the client looks at the world, how the resource manager looks at the world, and an overview of the two cooperating layers in the library, it's time to focus on the details.
Handler routines
Not all outcalls correspond to client messages—some are synthesized by the kernel, and some by the library.
Alphabetical listing of connect and I/O functions
This section gives an alphabetical listing of the connect and I/O function entry points that you can fill in (the two tables passed to resmgr_attach()). Remember that if you simply call iofunc_func_init(), all these entries will be filled in with the appropriate defaults; you'd want to modify a particular entry only if you wish to handle that particular message. In the Examples section, below, you'll see some examples of the common functions.
Examples
I'm now going to show you a number of cookbook examples you can cut and paste into your code, to use as a basis for your projects. These aren't complete resource managers—you'll need to add the thread pool and dispatch skeleton shown immediately below, and ensure that your versions of the I/O functions are placed into the I/O functions table after you've done the iofunc_func_init(), in order to override the defaults!
Advanced topics
Now that we've covered the basics of resource managers, it's time to look at some more complicated aspects.
Summary
Writing a resource manager is by far the most complicated task that we've discussed in this book.