> The requirement is to process get at any time irrespective of any other
> operation going on in parallel.
> But process only one set at a time.
> As the number of incoming requests could be very high, I went for thread-pool
> So now my server allocates a thread for each request from the threadpool.
> The set operation acquires a mutex lock before proceeding.
> The problem is...if there are many set requests at a time, all threads from the
> thread pool are used to process them and they all will be blocked on a mutex. No
> thread will be available to service the get request.
From your description, you want a form of reader/writer lock. You can write
such a lock quite easily. A good description can be found in Kleiman,
"Programming with Threads", Prentice Hall. The implementation given there
gives preference to writers, but can easily be modified to give preference
Quote:> Any suggetions for this pb?
One way would be to have two pools, one for writers and one for readers.
You can then control the size of each pool separately and ensure that
a large number of writers cannot cannot use up all available threads.
Another option (probably better) would be to give a thread to a writer
only if there isn't a writer active at the moment. To do this, you
will have to do your own thread creation though.
Quote:> Instead of relying on the ORB to allocate a thread from the pool, can I move
> this allocation of a thread to my application.
> The idea is very vague for me..
> Basically, my aim is to have few threads free to accept get request at any time.
> Can someone explain me how do I use my own thread pool implementation to handle
> synchronous events.
That depends entirely on your ORB, because none of this is prescribed by
the standard. Some ORBs will allow you to implement your own threading
model, essentially by using the strategy pattern and allowing you to implement
your own thread strategy. But you'll have to look at your ORB documentation
to see whether that is possible.
Michi Henning +61 7 3324 9633
Chief CORBA Scientist +61 4 1118 2700 (mobile)
IONA Technologies +61 7 3324 9799 (fax)
Total Business Integration http://www.ooc.com.au/staff/michi