Create a device and attach it to a process

I don’t know if it is possible, but i would like to know how could i create a device (dev/device_created ) and attach this device to a process.

For example, i have a process that simulates a temperature sensor, another process that simulates a cooler, and finally a process (named control) that reads the temperature and make works the cooler.
Using message passing between process its easy, but that’s no my idea.
I’m trying to attach those procees (temperature and cooler) to a decive. (dev/temp1 and dev/cool1). So, the control process would try to read and write in those device (temp1 and cool1) and they will simulate that there is a real device connected there.
am i clear?


This is exactly what a resource manager does, quickly, easily, and affectively I might add. Take a look at the documentation on resource managers. Bob Krten also has a really good book out that covers this area in great detail, although I don’t know if it is currently available.
Message passing is an integral part of the structure of all QNX devices/resource-managers. The basic idea is that you register a piece of name space, for example “/dev/temp1” with the OS. Thereafter, user calls to open("/dev/temp1",…) are turned into messages to your process. If your process responds with the proper reply message, the user/client process may make other calls, for example, read/write/close/ioctl. All these calls are again turned into standard format QNX messages. The provided resource manager library does a lot of work for you by providing reasonable defaults for all these calls, and you merely have to override these for the calls you need to customize.

Thanks maschoen . Yes, i have read some pdf from I’ve use a resurce manager with 2 prcess, i have registered a server doing this: attach = name_attach(NULL, SERVER_NAME, 0). After that, i use MsgCalls (MsgSend, MsgReceive)… I would try to do the same, but using a device /dev/temp1. I’m doing an intresting project, after i will tell all the details.
Thaks again
Bye :slight_smile:

The name_attach() and name_open() functions are not fully qualified resource managers. They solve the problem of name location (although they allow you to put names only under /dev/name/) but they do not provide support for the POSIX cover functions (like open(), read() and write()). You need a full resource manager to do this. Suggest you start off with the example “Simple resource manager” in the programmer’s guide, chapter “Writing a Resource manager” (which is essential reading anyway). There are also working examples for handling write() and read() messages from clients, which is basically all you need. The nice details can be added later.


Thanks Albrecht. I will read that chapter.