Multithreaded resource manager

Hi!

I have a simple multi-threaded resource manager as described here (http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/prog/resmgr.html#SIMPLE_MT_EG) and I have created and connected 2 IO handlers for read() and write() to resmgr_io_funcs_t structure. Both of these handlers contains infinite sleep() call, so when I call read() or write() from client process, I get stuck. This behavior is OK. But the thing is that when I run first client process with read() and then second client process with write() (both connecting to the same device (node of resource manager)) I can see that only one of my IO handler functions was entered. Is this behavior OK when I am using multi-threaded resource manager?

Thanks for answer.

Presumably, both the read and write are to the same device? What’s happening is that the resmanager library is protecting a control block with a mutex. That is why the 2nd call is never entered. To fix this, inside each call before it goes to sleep, it will have to release the mutex, and then when it wakes up, it will have to obtain it again. If that is not enough to get you going, I can give you more details.

Thanks!

Can you give me more info how to release this mutex you are talking about?

Thank you again.

michal

Sure,

Here is code from inside a read routine.

iofunc_attr_unlock(ocb->attr);

/* Wait for more data */

iofunc_attr_lock(ocb->attr);

The write routine does the same thing. Hidden in the iofunct_addr_…() calls is
the locking and unlocking of a mutex.