Re: [PATCH 1/19] MUTEX: Introduce simple mutex implementation

From: Nikita Danilov
Date: Thu Dec 15 2005 - 14:02:09 EST


Linus Torvalds writes:
>
>
> On Thu, 15 Dec 2005, linux@xxxxxxxxxxx wrote:
> >
> > A counting semaphore is NOT a perfectly fine mutex, and it SHOULD be changed.
>
> Don't be silly.
>
> First off, the data structure is called a "semaphore", and always has
> been. It's _never_ been called a "mutex" in the first place, and the
> operations have been called "down()" and "up()", because I thought calling
> them P() and V() was just too damn traditional and confusing (I don't
> speak dutch, and even if I did, I think shortening names to that degree is
> just evil).
>
> And dammit, a counting semaphore (and usually you don't even say the
> "counting" part, since counting is really always there) is just about
> _the_ classical mutual exclusion mechanism. If somebody doesn't know that,
> he has absolutely _no_ place talking about mutexes etc.

Dijkstra (that cannot talk about this due to much more serious reasons)
didn't know this, because semaphores were initially used as a
wait/signal mechanism to provide concurrency control between "process
context" and "interrupts" however they were called at the time, and
calling this "just mutual exclusion" is stretching a bit far.

Mutex implies usage pattern much narrower than generic semaphore.

>
> And a semaphore _is_ a mutex.

Nope, a mutex is a semaphore and not other way around. For one thing, a
notion of ownership is well-defined for the mutex, but it is not for a
semaphore. This is what they call "sub-type".

> Anybody who disputes that is just being a
> total troll.

Oh wait... what is that thing on the right of my screen? This
is... gnome task-list!

[...]

>
> And I can't understand how somebody has the balls to even say that a
> semaphore isn't a mutex. That's like saying that an object of type "long"
> isn't an integer, because only "int" objects are integers. That's just
> INSANE.

And the person that claims that "long" is an "int" is non-portable. :-)

[...]

>
> Linus

Nikita.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/