How to use Resource Manager

I am writing a usb driver of composite device that include Audio,Video,HID
My question is :
I should register one Resource Manager or three Resource Managers?


I think is a matter of design. I recommend you to take some time to read more documentation. DO you need 1 RM? 3? 5? A pool of threads?. How are you going to manage the communication of your driver with the application programs?.. You should ask yourself all this question an even more before you start typing.

read-think-desing / read-think-desing / read-think-desing / read-think-desing / CODE! (and read-think-desing again) :smiley:


When you say “register on Resource Manager or three” do you mean register one name space or three? That would be personal preference, but there is no significant difference in performance. If it is one physical device on the USB, then I think you will need to write this as one resource manager.

As maschoen said, if it is one device on the usb bus i would use one RM.
If there are more devices, so one for audio, one for video one for HID and they should be usable independently i would personally split it into 3 RM, since it would make the code less complex ^^.

The only reason not to have a single process for the resource manager would be fault tolerance. For instance, less code in each process space means each resource manager has a lower probability of containing a fatal flaw, and if one of the resource manager processes encounters a fault and crashes, the other two services would continue un-interrupted.

The advantage, is that the clients using the other resources, would not be temporally impacted by having to re-connect when the one resource faulted (and is presumably re-started).

Because of USB’s inherent design, there are no special steps to take in the three process case (i.e. no need to manage access to the hardware because the USB stack already does that). If your driver talked directly to the hardware then you’d need to concoct a synchronization mechanism for the hardware (e.g. a mutex in shared memory).

I pretty much agree with rgallen but I think the poster was saying that the same device at the end of the USB does 3 different things. Now if it appears as three different USB devices on the USB then I would recommend three different managers. If they appear as one single device however, you might have to synchronize access between the managers, in which case a single manager would probably be easier.

Thanks very much.

In the usb device,audio,vieo,hid do different I think 3RM is better