News for hackers. Stuff that matters.
Re:Linus Torvalds on semaphores (1999) by robert_tweed on Wednesday December 17, 2014 @03:37AM (#8761590)
"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)."

Quotes like this are why I always read what Linus has to say, regardless of whether the subject is relevant to my life in the slightest.

Edit: Yes people, those Dutch words exist! I get it! I'm sure Linus was well aware of that when he made this remark. However, the point Linus was making (in a humorous way) was that like most computer scientists / mathematicians, Dijkstra was overly fond of obscure, single-letter names, which nobody ever intuitively understands. Whereas the names "up" and "down" (see the rest of Linus' quote) are far more intuitive. Personally, I would argue that "hold" and "release" convey the intent in a clearer, more abstract way.

Re:Linus Torvalds on semaphores (1999) by otherusername on Wednesday December 17, 2014 @05:03AM (#8761758)
To say that a mathematician doesn't intuitively understand single-letter names would be like saying a programmer doesn't intuitively understand a keyboard.

Dijkstra was a computer scientist in times where being a computer scientist meant you were basically a mathematician with a specialty. Semaphores were first introduced by him in one of his early EWDs (EWD35, http://www.cs.utexas.edu/users/EWD/ewd00xx/EWD35.PDF). At the time of EWD35, his EWDs were non-official musings, written in Dutch, intended to be shared amongst interested colleagues and such. It's not like he was writing a scientific paper.

I don't think Torvalds really meant anything much by it. He's just trying to be funny.

Re:Linus Torvalds on semaphores (1999) by learnstats2 on Wednesday December 17, 2014 @07:34AM (#8762056)
> However, the point Linus was making (in a humorous way) was that like most computer scientists / mathematicians, Dijkstra was overly fond of obscure, single-letter names, which nobody ever intuitively understands.

If he was making this point, I find it ironic, considering that the purpose of the post is to explain the distinction between two obscure, poorly-named technical words, which nobody ever intuitively understands.

Re:Linus Torvalds on semaphores (1999) by viraptor on Wednesday December 17, 2014 @08:17AM (#8762167)
Hi, I'm nobody. You use spinlock to spin in place until you can get the lock. You wait at semaphores. Seems very intuitive to me.
Re:Linus Torvalds on semaphores (1999) by learnstats2 on Wednesday December 17, 2014 @08:51AM (#8762260)
semaphore

(ˈsɛməˌfɔː) n 1. (Telecommunications) an apparatus for conveying information by means of visual signals, as with movable arms or railway signals, flags, etc 2. (Telecommunications) a system of signalling by holding a flag in each hand and moving the arms to designated positions to denote each letter of the alphabet vb 3. (Telecommunications) to signal (information) by means of semaphore

which definition fits your understanding that you 'wait'? It's not a good name.

Re:Linus Torvalds on semaphores (1999) by viraptor on Wednesday December 17, 2014 @09:00AM (#8762295)
There are more meanings for semaphore:

https://en.wikipedia.org/wiki/Railway_semaphore_signal

Edit: Ok, actually that could be within your first meaning. But the practical result for railway semaphores is that one of their uses is to stop trains from entering a blocked segment.

Re:Linus Torvalds on semaphores (1999) by couchand on Wednesday December 17, 2014 @09:34AM (#8762374)
It's actually quite reasonable to complain about the use of the term semaphore here. As you recognize, stopping the train is only one of their uses. Railway signals can convey many different types of information about the state of the track, not just free/blocked.

And moreover, a semaphore is just a specific type of railway signal, one with a pivoting arm. It's very hard to see how a pivoting arm is at all related to the CS concept.

Re:Linus Torvalds on semaphores (1999) by viraptor on Wednesday December 17, 2014 @10:10AM (#8762498)
Not sure if it's reasonable to complain really... I mean, it's not covering everything semaphores do, but the basics are there - gives information and stops two trains/threads colliding. References to trains when talking about cs semaphores are all over the place. Universities:

http://ro.uow.edu.au/cgi/viewcontent.cgi?article=1027&contex...

http://courses.teresco.org/cs432_f02/lectures/07-synch/07-sy...

https://www.cs.cmu.edu/~410-f03/lectures/L09_Synch.txt

https://www.cs.ucsb.edu/~rich/class/cs170/notes/Semaphores/

Documentations:

https://doc.micrium.com/display/osiiidoc/Semaphores+in+uC-OS...

Articles:

http://realtimepartner.com/articles/semaphores.html

http://lycog.com/distributed-systems/semaphore-mutual-exclus...

If we're going to compare it to any real life object, it may as well be a semaphore. Anything else will have the same issues. Traffic lights: what about yellow / blinking. Stop signs: why do they sometimes stop, sometimes not. etc.

Is there any single word/phrase concept which you'd rather use instead? Is it much more convenient and clear than a semaphore?

Re:Linus Torvalds on semaphores (1999) by couchand on Wednesday December 17, 2014 @12:25PM (#8763157)
Is it much more convenient and clear than a semaphore?

My point was simply that the only reason "semaphore" is clear is that you've already heard or read those lectures talking about it. There's nothing about the railroad meaning of the term that would imply the computer science meaning. A counter that can never go below zero is entirely unrelated to a pivoting arm. Once you know the connection it can serve as something of a reminder, but that's different from having an intuitive understanding in the first place.

EDIT: Getting from RR semaphore to CS semaphore requires several leaps of intuition. On the railroad side you need to recognize that it is a signal that's important, and it's irrelevant whether that signal is implemented as a semaphore, an electric signal, or even a flagman. On the computer science side you need to know the difference between a semaphore and the many other types of mutual exclusion mechanisms.

So in that sense "semaphore" is poorly named: it provides insufficient context to distinguish the concept from other similar, yet distinct, ideas.

Re:Linus Torvalds on semaphores (1999) by tcheard on Wednesday December 17, 2014 @04:36PM (#8764505)
Since when does a name have to provide sufficient context to distinguish the concept from other similar, yet distinct, ideas?

For example, tree data structures. There are:

2–3 tree, 2–3–4 tree, AA tree, (a,b)-tree, AVL tree, B-tree, B+ tree, B*-tree, Bx-tree, Binary search tree, Optimal binary search tree, Dancing tree, HTree, Interval tree, Order statistic tree, Red–black tree, Scapegoat tree, Splay tree, T-tree, Treap, UB-tree

In many of those the name doesn't provide much context at all to distinguish the concept from another one.

Names of things, at least in CS, are rarely ever named in a way to provide sufficient context of their meaning, without having some level of background context.

That is what the description of the concept is for, not the name. A name is too short to provide this. Usually the name is at the discretion of the original author (aka Dijkstra in this case). If you are trying to determine the complete concept of something, or you are trying to distinguish the concept from other similar ideas, only from the name, you are doing it wrong. Go read the documentation about the concept for that.

Re:Linus Torvalds on semaphores (1999) by couchand on Wednesday December 17, 2014 @05:44PM (#8764838)
I'm not saying a name has to provide sufficient context. I'm saying a name that provides that context is superior to one that does not.

A red-black tree is named so because those were the colors their laser printer supplied. This is (much like semaphore) a historical accident. Yet, just by the name red-black, you do indeed have enough context to distinguish it from a plain old binary search tree. The defining feature is that you color every node either red or black, thus red-black in the name.

Likewise with splay tree: the defining function is the splay operation, which the name is a vivid reminder of.

Splay tree and red-black tree are Good Names (TM). B tree, B+ tree, B* tree, Bx tree are Bad Names (TM).

Re:Linus Torvalds on semaphores (1999) by drcomputer on Wednesday December 17, 2014 @06:03AM (#8761873)
> most computer scientists / mathematicians, Dijkstra was overly fond of obscure, single-letter names, which nobody ever intuitively understand

If you use a word too common, it's too easy to confuse the definition of that word with the definition of its use in a different context. You must not understand the pain of reading two mathematical books and trying, with the utmost sincerity, to figure out whether the authors are actually using the words the same (such as set, relation, abstraction, object, even things like function). There's the distinct definition, and there is the contextual use, which can theoretically differ for everyone depending on the origin path of native language. You can never know if someone is altering the definition or discovering / describing something new, and they are using the wrong word. Discovering the perfect word for the concept you construct in code or math is an art.

Re:Linus Torvalds on semaphores (1999) by tomp on Wednesday December 17, 2014 @04:53AM (#8761731)
Me too. I just love this guy. Sure, some people find him insulting, but I call that "funny".
Re:Linus Torvalds on semaphores (1999) by outworlder on Wednesday December 17, 2014 @07:09AM (#8761993)
> "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 @transmeta address?

That's grounds for termination in many companies, even if you don't get lawyers involved. I think he's only able to get away with it because he's Linus.

Re:Linus Torvalds on semaphores (1999) by ANTSANTS on Wednesday December 17, 2014 @07:49AM (#8762084)
Technically, you're right. Today, any junior employee that made a joke like that would be crucified and practically blacklisted from the industry. What you should be thinking, however, is not "why does Linus get away with saying things like that?" but rather "why do I consider it normal for someone's livelihood to be permanently destroyed over a stupid joke?"
Re:Linus Torvalds on semaphores (1999) by serve_yay on Wednesday December 17, 2014 @12:04PM (#8763040)
Gosh, no kidding.
Re:Linus Torvalds on semaphores (1999) by GFK_of_xmaspast on Wednesday December 17, 2014 @07:59AM (#8762117)
What do you think an appropriate response is?
Re:Linus Torvalds on semaphores (1999) by kyberias on Wednesday December 17, 2014 @08:53AM (#8762266)
The appropriate response is to immediately start thinking why you need to figure out a response to any low-quality joke people make. Maybe, just maybe, there is absolutely no need to make any response whatever. Think about it.
Re:Linus Torvalds on semaphores (1999) by ANTSANTS on Wednesday December 17, 2014 @08:16AM (#8762161)
I think if people would stop pretending to be offended by ridiculous things, the problem would solve itself and we wouldn't need to have a "response" in the first place.
Re:Linus Torvalds on semaphores (1999) by Igglyboo on Wednesday December 17, 2014 @08:47AM (#8762248)
Nothing because it's quite obviously a joke.
Re:Linus Torvalds on semaphores (1999) by jpitz on Wednesday December 17, 2014 @08:14AM (#8762154)
How about public shaming instead of the destruction of a career?
Re:Linus Torvalds on semaphores (1999) by CamperBob2 on Wednesday December 17, 2014 @04:32PM (#8764492)
That's the idea. Any developer or researcher who uses obscure or meaningless names like "P" and "V" needs to be publicly shamed for it, no matter how well-respected they are. Clarity is vital in this business.

Or were you talking about Linus?

Re:Linus Torvalds on semaphores (1999) by ANTSANTS on Wednesday December 17, 2014 @09:58AM (#8762440)
They're one and the same in this witch-hunt culture.
Re:Linus Torvalds on semaphores (1999) by ramblerman on Wednesday December 17, 2014 @07:17AM (#8762009)
I'd argue 'false drama' is the real culprit. A bit like your comment is adding to this thread.
Re:Linus Torvalds on semaphores (1999) by andrewstuart2 on Wednesday December 17, 2014 @08:21AM (#8762179)
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) by AnimalMuppet on Wednesday December 17, 2014 @12:58PM (#8763353)
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.)
Re:Linus Torvalds on semaphores (1999) by xxs on Wednesday December 17, 2014 @01:56PM (#8763651)
Actually, Linus is from Helsinki that's not exactly close to The Netherlands. There is no intrinsic connection between Finland and The Netherlands. Although the drug laws are still famous all over.
Re:Linus Torvalds on semaphores (1999) by AnimalMuppet on Wednesday December 17, 2014 @03:15PM (#8764068)
Much closer than the US is...