26.02.2014 Views

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

© 2009, <strong>QNX</strong> <strong>Software</strong> <strong>Systems</strong> GmbH & Co. KG. Writing a resource manager<br />

The third parameter is different, however. It’s an ocb, which stands for “Open Context<br />

Block.” It holds the context that was bound by the connect message handler (e.g., as a<br />

result of the client’s open() call), and is available to the I/O functions.<br />

As discussed above, when it comes time to fill in the two tables, we recommend that<br />

you use the iofunc_func_init() function to load up the tables <strong>with</strong> the POSIX-layer<br />

default handler routines. Then, if you need to override some of the functionality of<br />

particular message handlers, you’d simply assign your own handler function instead of<br />

the POSIX default routine. We’ll see this in the section “Putting in your own<br />

functions.”<br />

The resmgr_context_t internal context block<br />

Finally, one data structure is used by the lowest layer of the library to keep track of<br />

information that it needs to know about. You should view the contents of this data<br />

structure as “read-only,” (except for the iov member).<br />

Here’s the data structure (from ):<br />

typedef struct _resmgr_context {<br />

int<br />

rcvid;<br />

struct _msg_info info;<br />

resmgr_iomsgs_t *msg;<br />

dispatch_t<br />

*dpp;<br />

int<br />

id;<br />

unsigned<br />

msg_max_size;<br />

int<br />

status;<br />

int<br />

offset;<br />

int<br />

size;<br />

iov_t iov [1];<br />

} resmgr_context_t;<br />

As <strong>with</strong> the other data structure examples, I’ve taken the liberty of deleting reserved<br />

fields.<br />

Let’s look at the contents:<br />

rcvid<br />

info<br />

msg<br />

dpp<br />

The receive ID from the resource manager library’s<br />

MsgReceivev() function call. Indicates who you should reply to (if<br />

you’re going to do the reply yourself).<br />

Contains the information structure returned by MsgReceivev() in<br />

the resource manager library’s receive loop. Useful for getting<br />

information about the client, including things like the node<br />

descriptor, process ID, thread ID, and so on. See the<br />

documentation for MsgReceivev() for more details.<br />

A pointer to a union of all possible message types. This isn’t very<br />

useful to you, because each of your handler functions get passed<br />

the appropriate union member as their second parameter.<br />

A pointer to the dispatch structure that you passed in to begin<br />

<strong>with</strong>. Again, not very useful to you, but obviously useful to the<br />

resource manager library.<br />

April 30, 2009 Chapter 5 • Resource Managers 209

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!