The programs that follow are complete but simple examples of a
device resource manager.
Note:
As you read through this guide, you'll encounter many code snippets.
Most of these code snippets have been written so that they can be
combined with either of these simple resource managers.
The first two of these simple device resource managers model their functionality after that
provided by /dev/null (although they use
/dev/sample to avoid conflict with the real
/dev/null):
- an open() always works
- read() returns zero bytes (indicating EOF)
- a write() of any size works (with the data being discarded)
- lots of other POSIX functions work
(e.g., chown(), chmod(), lseek())
The chapters that follow describe how to add more functionality to these simple resource managers.
Note:
The QNX Momentics Integrated Development Environment (IDE) includes
a sample /dev/sample resource manager that's very similar
to the single-threaded one given below.
To get the sample in the IDE, choose
, and then click the Samples icon.