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.

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

Summary<br />

Writing a resource manager is by far the most complicated task that we’ve discussed<br />

in this book.<br />

A resource manager is a server that receives certain, well-defined messages. These<br />

messages fall into two broad categories:<br />

Connect messages<br />

Related to pathname-based operations, these may establish a<br />

context for further work.<br />

I/O messages<br />

Always arrive after a connect message and indicate the actual work<br />

that the client wishes to have done (e.g., stat()).<br />

The operations of the resource manager are controlled by the thread pool functions<br />

(discussed in the Processes and Threads chapter) and the dispatch interface functions.<br />

QSS provides a set of POSIX helper functions in the resource manager library that<br />

perform much of the work of dealing <strong>with</strong> the client’s Connect and I/O messages that<br />

arrive.<br />

There are a number of data structures relating to the clients and devices manifested by<br />

the resource manager to keep in mind:<br />

OCB<br />

Attributes structure<br />

Mount structure<br />

Allocated on a per-open basis, this contains the context for the<br />

client (e.g., current lseek() position)<br />

Allocated on a per-device basis, this contains information about<br />

the device (e.g., size of the device, permissions, etc.)<br />

Allocated on a per-resource-manager basis, and contains<br />

information about the characteristics of the entire resource<br />

manager.<br />

The clients communicate <strong>with</strong> the resource manager via message passing by resolving<br />

the pathname (via the open() and other calls) into a node descriptor, process ID,<br />

channel ID, and handle.<br />

Finally you supply the functionality you wish to actually do in your resource manager<br />

by overriding some of the callouts in the Connect and I/O functions table.<br />

April 30, 2009 Chapter 5 • Resource Managers 283

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

Saved successfully!

Ooh no, something went wrong!