Nice read, but still some misconceptions and misunderstandings. If I am in a multiprocessor design, where each processor runs completely independent from each other and there is no central organizational unit like a central OS, like in many embedded designs, there is no such thing as a spinlock. A semaphore is also not used for sending processes to sleep. Linus explanation makes sense, speaking only about a single OS…
Linus Torvalds on semaphores (1999)
81–90 of 112 posts
Re: Linus Torvalds on semaphores (1999)
#82Earlier quoted context omitted.
> "Dijkstra was probably a bit heavy on drugs or something (I think the official explanation is that P and V are the first letters in some Dutch words, but I personally find the drug overdose story much more believable)." I personally have made remarks that were WAY more potentially offensive than that, verbally, with friends. But, accusing Dijkstra of being a drug user, on the Linux kernel mailing list, from a @tran…
Dijkstra was Dutch and lived in the Netherlands, where drug policies are either nonexistent or loosely enforced. So perhaps it's less offensive than it seems on the surface.
Re: Linus Torvalds on semaphores (1999)
#83Here's Dijkstra's original paper on P and V (in Dutch), from about 1963. http://www.cs.utexas.edu/users/EWD/transcriptions/EWD00xx/EW... Here is a implementation of P and V, the original counted semaphore primitives, from 1972. http://www.fourmilab.ch/documents/univac/fang/ This is UNIVAC 1108 assembly code. Along with P and V is the code for bounded buffers, with the operations "PUT" and "GET". Bounded buffers are w…
Re: Linus Torvalds on semaphores (1999)
#84Earlier quoted context omitted.
Well, P and V are considered harmful (pun intended). Systems using these operations are in general not "composable". In other words, it is usually not possible to compose two software systems using semaphores and/or mutexes, without rewriting these systems somehow. Alternatives exist. For example: message passing, and STM (software transactional memory). Anybody know of other alternatives?
> Alternatives exist. For example: message passing, and STM (software transactional memory). Anybody know of other alternatives? It should be noted that spinlocks, mutexes and conditions (and semaphores) are building blocks that are necessary to implement message passing, software transactional memory and other non-trivial parallel programming constructs. (at least until we have practical hardware transactional memor…
Re: Linus Torvalds on semaphores (1999)
#85Earlier quoted context omitted.
For those wondering, P comes from 'Passering', roughly translated 'pass' (as a noun), and V from 'Vrijgave' ('release'). Apparently somehow this terminology comes from train systems but there's not a lot of context on that etymology. As an aside, this paper (it's actually the transcription of a lecture) has some great metaphors that explain problems with concurrence and issues with synchronisation. At the risk of los…
An amusing anecdote I heard about this a few weeks ago: he came up with "P" and "V" when explaining the concept to his students at Eindhoven University. He looked outside the window of the classroom he was teaching in and saw the name of the local soccer club on a nearby stadium which is PSV.
Re: Linus Torvalds on semaphores (1999)
#86Earlier quoted context omitted.
If you're talking about building blocks, goto is also a necessary evil...
You will be surprised at the goto use in the linux kernel...
goto is harmful when used improperly but fine everywhere else.
Re: Linus Torvalds on semaphores (1999)
#87Nice read, but still some misconceptions and misunderstandings. If I am in a multiprocessor design, where each processor runs completely independent from each other and there is no central organizational unit like a central OS, like in many embedded designs, there is no such thing as a spinlock. A semaphore is also not used for sending processes to sleep. Linus explanation makes sense, speaking only about a single OS…
Re: Linus Torvalds on semaphores (1999)
#88Earlier quoted context omitted.
You will be surprised at the goto use in the linux kernel...
goto is perfectly acceptable in C code. The most common use case is for cleaning up after errors before returning, although they're also used to break out of nested loops cleanly. goto is harmful when used improperly but fine everywhere else.
Re: Linus Torvalds on semaphores (1999)
#89Earlier quoted context omitted.
STM and message parsing do require the low level primitives: CAS (CompareAndSet/Swap), LL/SC (Load linked/store conditional). Morealso STM doesn't solve the transactional problem that you face with using locks (mutex). Overall STM is just a fancy thing to have but hardly solves the big problem of transaction boundaries. Message passing is easier to reason about due to global ordering but then you need some FIFO queue…
STM with database style transactions like in clojure? http://clojure.org/refs
Re: Linus Torvalds on semaphores (1999)
#90Earlier quoted context omitted.
Dijkstra was Dutch and lived in the Netherlands, where drug policies are either nonexistent or loosely enforced. So perhaps it's less offensive than it seems on the surface.
And Linus, who grew up much closer to the Netherlands than many of us, was probably aware of that. (I had forgotten it until you pointed it out.)