On 2008-03-18 12:53:37, Lars Uffmann wrote:
> Fei Liu wrote:
>> lock attempts are never queued. lock is acquired when a lock is not
>> bound and a thread attempts to acquire it.
>
> Hmm... I'm not sure what the C++ standardization committee is about to
> implement, but the "basis" for that implementation in boost seems to be
> queueing lock attempts:
>
> - thread a gets a lock on mutex m
> - thread b attempts to acquire a lock on m, and locks
> - thread a unlocks m
> - thread b now gets the lock on m and proceeds
>
> That's how it is behaving. Just for the record :)
There is no "queue" here. Ok, there is a queue of 1 thread waiting -- but
with one member, there's no difference between a stack, a queue, a set,
...
:)
The thing is if several threads b1, b2, b3, ... are waiting on m (and have
attempted to acquire the lock in that order), there is nothing in the
language that guarantees that they will acquire the lock in that order. If
so, it would be a queue. It's not, so it isn't really a queue.
Gerhard


|