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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Writing a resource manager<br />

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

resmgr_attach()<br />

resmgr_detach()<br />

pulse_attach()<br />

pulse_detach()<br />

Creates a channel, associates a pathname, dispatch handle,<br />

connect functions, I/O functions, and other parameters together.<br />

Sends a message to the process manager to register the<br />

pathname.<br />

Opposite of resmgr_attach(); dissociates the binding of the<br />

pathname and the resource manager.<br />

Associates a pulse code <strong>with</strong> a function. Since the library<br />

implements the message receive loop, this is a convenient way<br />

of “gaining control” for handling pulses.<br />

Dissociates a pulse code from the function.<br />

In addition to the functions listed above, there are also numerous functions dealing<br />

<strong>with</strong> the dispatch interface.<br />

One function from the above list that deserves special mention is resmgr_open_bind().<br />

It associates some form of context data when the connect message (typically as a<br />

result of the client calling open() or fopen()) arrives, so that this data block is around<br />

when the I/O messages are being handled. Why didn’t we see this in the /dev/null<br />

handler? Because the POSIX-layer default functions call this function for us. If we’re<br />

handling all the messages ourselves, we’d certainly call this function.<br />

The resmgr_open_bind() function not only sets up the context block for further I/O<br />

messages, but also initializes other data structures used by the resource manager<br />

library itself.<br />

The rest of the functions from the above list are somewhat intuitive — we’ll defer their<br />

discussion until we use them.<br />

The POSIX layer<br />

The second layer provided by QSS’s resource manager library is the POSIX layer. As<br />

<strong>with</strong> the base layer, you could code a resource manager <strong>with</strong>out using it, but it would<br />

be a lot of work! Before we can talk about the POSIX-layer functions in detail, we<br />

need to look at some of the base layer data structures, the messages that arrive from<br />

the clients, and the overall structure and responsibilities of a resource manager.<br />

Writing a resource manager<br />

Now that we’ve introduced the basics — how the client looks at the world, how the<br />

resource manager looks at the world, and an overview of the two cooperating layers in<br />

the library, it’s time to focus on the details.<br />

In this section, we’ll take a look at the following topics:<br />

• data structures<br />

• resource manager structure<br />

204 Chapter 5 • Resource Managers April 30, 2009

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

Saved successfully!

Ooh no, something went wrong!