guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Futures: Avoid creating the worker pool more than once


From: Mark H Weaver
Subject: Re: [PATCH] Futures: Avoid creating the worker pool more than once
Date: Fri, 09 Nov 2012 22:13:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

address@hidden (Ludovic Courtès) writes:

> Mark H Weaver <address@hidden> skribis:
>
>> +  ;; setting 'create-workers!' to a no-op is an optimization, but it is
>> +  ;; still possible for '%create-workers!' to be called more than once
>> +  ;; from different threads.  Therefore, to avoid creating %workers more
>> +  ;; than once (and thus creating too many threads), we check to make
>> +  ;; sure %workers is empty within the critical section.
>
> Do you have a scenario where this happens?

I'd hoped that the comment above was clear, but let me try again.

If two threads simultaneously call 'make-future' before the worker pool
has been created, then both threads can call 'create-workers!' (before
it has been rebound), and from there both can enter '%create-workers!'.

At that point, unless one of the threads is killed, it is guaranteed
that both will enter the critical section: first one, and then the other
(after the first one has unlocked the mutex).  Thus, two worker pools
will be created (though the first worker pool will become inaccessible).

      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]