digitalmars.D - Re: Thin Locks in D
- Alberto Bertogli <albertito blitiri.com.ar> Jul 25 2008
On Fri, Jul 25, 2008 at 01:17:58PM -0400, superdan wrote:Leandro Lucarella Wrote:Sean Kelly, el 24 de julio a las 23:09 me escribiste:Lionello Lunesu wrote:"Walter Bright" <newshound1 digitalmars.com> wrote in message news:g6b1ae$up4$1 digitalmars.com...http://bartoszmilewski.wordpress.com/2008/07/24/thin-locks-in-d/ and of course on reddit: http://www.reddit.com/comments/6tbzc/thin_locks_in_d/
They pretty much do. And futexes are largely the same thing in Linux.
So, why D must reinvent the wheel, duplicating a well known technique done in most modern OS? This will only add overhead to D. Please, at least make it conditional only to OSs that don't provide this optimization by themselves.
there is no reinvention. the man quotes his sources. at most there is reimplementation. and that's unavoidable as far as i understand. thin locks must be integrated with the object model so they place that word right there and do shit with it.
No, it's not unavoidable. If you just use Linux' futexes (or, from what I read on this threads, Windows' too), you get those "thin locks" *for free*. You don't have to implement the whole CAS-based mechanism with fallback to the OS' locks, just use the locks directly: they implement the same trick. Obviously I think the trick is quite nice (and there are several articles on lwn.net describing Linux' implementation in detail, besides "man 7 futex", if you are interested), and if the underlying OS doesn't support it, it's obviously worth it. But at least Linux has been using it for years, and you gain nothing by using it on that platform. So the only thing you are going to gain on the platforms that already do it is a nice layer of overhead. Thanks, Alberto
Jul 25 2008