Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Resource Manager with Multiple Clients: (3 Items)
   
Resource Manager with Multiple Clients  
Hi 

I'm developing a resource manager that can have multiple clients. The RM will receive data from a driver, and transmit 
it to each client. Clients can either read (BLOCKED) or use select. 

I'm relatively new to QNX, but have worked on frameworks with similar setups.

As far as I can see, if I want to ensure that each client gets the messages, then I will have to have a "Queue" for each
 client.

Q - can I add this Queue to an extended OCB? Then if data arrives, it can be sent (If the client is waiting) or can be 
added to the client's OCB for the next "read". (If the client is currently not waiting.)

I guess it'll be something like:

message arrives from lower level.
for each client
    if client is waiting (i.e there's a stored rcvid.), do MsgSend
else
   add message to client's list (In OCB?)

I'll also be using notiications, so select can be used as well.

I am not sure if what I am trying to do is barking mad not or - or if there's a means of obtaining the list of "OCB" 
objects for a resource and then querying them to see if they're READING and therefore require data...

I'd be grateful for any advice or hints...
(I have read the QNX resource manager details in detail, and think I'm sort of the right track, but as I'm new to this 
OS, there's always some doubt.)



Re: Resource Manager with Multiple Clients  
Hi,

in general, your approach looks quite good. Within the resmgr framework, you'll need to pay attention to a few points, 
though.

First, while it's theoretically ok to queue the incoming data for all (read) clients, you should be aware that this way,
 a client that did an open() but never performs a read() could easily crash at least your driver with a memory overflow.
 Usually one would prefer having a fixed-size buffer within the driver and run the risk that the client misses some data
 if it doesn't keep up reading.

Also, what you shouldn't do is  MsgSend()  to a client from a resource manager - it is supposed to receive and reply 
only. Best extend your ocb so that you can maintain a list of read-blocked clients. In your io_read handler, if no data 
is available, insert the ocb into that list and do not reply. When new data arrives, walk that list and reply the new 
data to all the blocked clients. 

For the select-handling, use iofunc_notify() to insert select()ing clients into a list of blocked clients, and upon data
 arrival do
  iofunc_notify_trigger( nop, 1, IOFUNC_NOTIFY_INPUT )

Hope this helps,
- Thomas
Re: Resource Manager with Multiple Clients  
Thanks - that is very helpful indeed. Being new to an OS with very tight timescales is proving somewhat stressful.