Live data from Hacker News

Linus Torvalds on semaphores (1999)

yarchive.net

91–100 of 112 posts

Re: Linus Torvalds on semaphores (1999)

#91
post #27

Earlier quoted context omitted.

> This stuff was all well understood four decades ago. Much of it was forgotten outside the mainframe world, because threads and multiprocessors didn't make it to microprocessors for several more decades. Here's an important distinction to make: this stuff was well understood in theory , but the practice is a bit different. Semaphores are a neat theoretical concept but not a very good practical parallel programming p…

Using two semaphores to implement a bounded buffer has the advantage that writers and readers don't interfere with eachother until the queue is either empty or full. Of course, that might be the only good use of semaphores, and a direct implementation can be better then one using standard semaphores. Semaphores can be implemented in a way that doesn't require a spinlock in the fast path. Still not as fast as you can…

In practice, the semaphores available for many systems are considerably slower than using architecture provided atomic increment operations, which means implementing a bounded buffer with two counters and two mutexes ends up being faster.

Re: Linus Torvalds on semaphores (1999)

#92
post #19

If you haven't already, follow the 'index' link (to http://yarchive.net/comp/index.html ) and bookmark that. Some very worthwhile reading there.

That whole site is fascinating, I just lost like 2 hours of my life. Late 90s threads about TLB strategies from @sgi.com e-mail addresses? F&$% me, I could read that sort of stuff all day. (I started http://www.snakebite.org, for reference.)

Re: Linus Torvalds on semaphores (1999)

#93
post #83
post #10

Here'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…

I think the UNIVAC implementation of P and V that you meant to link to is in http://www.fourmilab.ch/documents/univac/fang/hsource/schpro... .

Those are the assembler macros ("procs" in UNIVAC terminology) for calling the functions previously linked.

(UNIVAC assemblers were very powerful. Arbitrary computation could be done at assembly time. If you needed some precomputed table, that was the way to do it.)

Re: Linus Torvalds on semaphores (1999)

#95
post #88

Earlier quoted context omitted.

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.

I didn't mean it's a bad thing, it was a reply to some blanket statement.

I think you missed that fpgeek was turning exDM69's comment around on itself to put goto and spinlock into the same category.

fpgeek wasn't actually making a statement about goto

Re: Linus Torvalds on semaphores (1999)

#97
post #90

Earlier quoted context omitted.

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.)

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.

Much closer than the US is...

Re: Linus Torvalds on semaphores (1999)

#99
post #93
post #83

Earlier quoted context omitted.

I think the UNIVAC implementation of P and V that you meant to link to is in http://www.fourmilab.ch/documents/univac/fang/hsource/schpro... .

Those are the assembler macros ("procs" in UNIVAC terminology) for calling the functions previously linked. (UNIVAC assemblers were very powerful. Arbitrary computation could be done at assembly time. If you needed some precomputed table, that was the way to do it.)

The previous link just takes me to the FANG homepage frameset, which doesn't have any functions visible on it to me. This is a common problem with linking to framesets. Or is it some kind of problem in my browser, and other people see functions in UNIVAC assembly when they follow that link?

(FWIW, I think it's fairly normal for macro assemblers to be Turing-complete, although some of them carry it off more gracefully than others.)

Re: Linus Torvalds on semaphores (1999)

#100
post #51

Earlier quoted context omitted.

What do you think an appropriate response is?

How about public shaming instead of the destruction of a career?

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?

Post reply on HN