[omniORB] Method priorities
Sai-Lai Lo
S.Lo@uk.research.att.com
31 Aug 2000 13:53:07 +0100
>>>>> Matthew Berry writes:
> A server object is essentially multi-threaded and a new thread is created
> for each client request. I have a high priority client and a number of lower
> priority clients. The high priority client will always call method X, whilst
> the lower priority clients will call Y.
> I presume then that I can service the higher priority client "better" by
> setting the associated thread to a HIGH priority in method X. In the method
> Y I would set the priority to LOW. This would be achieve by putting a line
> at the beginning of X:
> omni_thread::self()->set_priority(PRIORITY_HIGH);
> Similarly Y's implementation would begin with
> omni_thread::self()->set_priority(PRIORITY_LOW);
> Is there a better or more elegant way of doing this?
Beware of priority inversion! Your high priority thread may go through
synchronisation points, either inside the ORB or in your applications,
where the low priority threads also have to go through. Since priority
inheritance or priority ceiling is not generally provided by pthread or
other thread implementations, you can easily ended up in a dead lock
situation if you're not careful.
If it is important to give predictable response time to high priority
clients, I think you cannot rely on the thread system to do that for you.
It is not elegant but I think you need to schedule the requests explicitly
with a priority queue. I.e. arrange the requests in a queue based on their
priority and dispatch worker threads to work from the top priority requests
downward.
Sai-Lai
--
Sai-Lai Lo S.Lo@uk.research.att.com
AT&T Laboratories Cambridge WWW: http://www.uk.research.att.com
24a Trumpington Street Tel: +44 1223 343000
Cambridge CB2 1QA Fax: +44 1223 313542
ENGLAND