Skip navigation.
The QNX Community Portal

View topic - Resource Manager with multiple clients

Page 1 of 1

Resource Manager with multiple clients

PostPosted: Wed Aug 11, 2010 9:35 am
by flapdoodle
Hi folks,
I'm creating a resource manager that will have many read clients. A lower level service passes data into the resource manager, which then passes it onto all clients. Clients will be using standard read/open/(maybe select as well).

I've got a basic RM up and running thanks to the docs on QNX's website. However, the example there shows a RM that uses the attribute block to store a list of received data. A read then consumes from this list and removes the last entry and passes it to the client

I'm porting the app from a system that has a framework similar to resource managers, but each client is allocated a "mail box" when it opens the device, and all mailboxes receive a copy of the data from the lower level. Clients then call read and the framework pulls data out of the mailbox.

My current thinking is that I can do this in QNX by using an extended OCB structure that has a per-client list of data (Rather than one per-device) and then a "read" consumes the list for that client.

Another alternative is to implement a per-device list and manage it in such a way that it only discards items when they've been read by all clients, in effect keeping a per-device queue with the latest received always at the head and the rest being those that that haven't been read by all clients. Naturally, there'll be a size limit to a list.

Has anyone created a RM like this before and got any advice (Or am I missing the point of something here...)


RE: Resource Manager with multiple clients

PostPosted: Wed Aug 11, 2010 3:13 pm
by mario
The OCB seems like a good approch to me. Your second approch seems to have the advantage of not have multiple copy of the same data but seems a little more complicated to implement.

PostPosted: Wed Aug 11, 2010 7:38 pm
by PeterHuber
Hi flapdoodle,

yes, extending the OCB and managing a read queue for each client is the proper design in my eyes. I propose to implement a reference counting mechanism for the data items instead of duplicating them for each client. But this is only necessary if you expect many clients and big data items.

- Peter

PostPosted: Thu Aug 12, 2010 6:48 pm
by flapdoodle
Thanks guys. Based on past experience, I suspected this would be the best approach - the data items are small and there won't be large streams of them, so duplicating them in the OCB for each client is not a problem. I could extend it later to add ref counting so they can be shared if there is a requirement to do so.

Is there an API call in the QNX layers to "get all attached OCBs" or will I have to keep my own list in the attribute structure (And add to it whenever there's an open.)