[concurrency-interest] santa clause problem solved?

Joe Bowbeer joe.bowbeer at gmail.com
Tue Apr 8 03:41:07 EDT 2008

On Mon, Apr 7, 2008 at 6:39 PM, David Holmes <dcholmes at optusnet.com.au> wrote:
>  3. Having the elves/reindeer wait for each other and then Santa.
>  The elves is a little trickier and I didn't quite see how your solution
>  worked. If the elves wait on a barrier with four parties, what triggers the
>  event when 3 arrive? Does your "reservation generator" keep track of
>  requests and post the event after every third request? That seems to work,
>  but there's a potential delay between an elf requesting the cyclic barrier
>  and actually waiting on it, so you might wait for thousands of elves to
>  block before the initial group of three all arrive at the barrier.
>  Another possibility is for all elves to try and grab a Semaphore with 3
>  permits. When they have that they wait on a barrier-3, the barrier task for
>  which posts the event to the queue together with a barrier-4, and then
>  signals the semaphore so the next 3 elves can get through. The elves then
>  wait on the barrier-4 until Santa arrives. I'm not sure how to manage the
>  references to the barrier-4 and it has the same delay problem :) Maybe delay
>  is unavoidable if all the elves rush to Santa at once :-)

I meant the former: the MeetingManager (as named in the code) posts a
task to Santa's queue when three Elves have arrived for a meeting.

Thanks for the comments.


More information about the Concurrency-interest mailing list