Queue.Queue-like class without the busy-wait
Nick Craig-Wood
nick at craig-wood.com
Sun Apr 3 14:30:02 EDT 2005
Paul Rubin <http> wrote:
> Nick Craig-Wood <nick at craig-wood.com> writes:
> > I believe futex is the thing you want for a modern linux. Not
> > very portable though.
>
> That's really cool, but I don't see how it can be a pure userspace
> operation if the futex has a timeout. The kernel must need to keep
> track of the timeouts. However, since futexes can be woken by any
> thread, the whole thing can be done with just one futex. In fact the
> doc mentions something about using a file descriptor to support
> asynchronous wakeups, but it's confusing whether that applies here.
No it isn't pure user space, only for the non-contended case which for
most locks is the most frequent operation.
Futex operation is entirely userspace for the non-contended
case. The kernel is only involved to arbitrate the contended
case. As any sane design will strive for non-contension,
futexes are also optimised for this situation.
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list