Thin Lock Implementation

Sean Kelly sean at invisibleduck.org
Tue Aug 19 13:29:23 PDT 2008


== Quote from Aarti_pl (aarti at interia.pl)'s article
> Bartosz Milewski pisze:
> > I posted some implementation details of Thin Lock in my blog,
> > http://bartoszmilewski.wordpress.com/ . I would appreciate comments.
> >
> > And by the way, I put it on reddit too:
> > http://www.reddit.com/comments/6wmq4/thin_lock_implementation/ .
> >
> > Bartosz
> Well, I am definitely no concurrency expert, but one questions bothers
> me a bit.
>  From your article it seems that there will be limit of 2046 threads for
> program (11 bits, one based).
> Isn't it too small number, taking into account multi core processors
> which will emerge (able to start much more threads than currently), and
> applications like web servers (which serves a lot of concurrent
> connections)?

I had the same concern, however, the compact thread id is clearly necessary
for the algorithm to operate properly, so what can you do.  Perhaps transfer
some bits from the recursion counter to the thread id to increase that number.

For what it's worth, Tango doesn't use a static thread list because I think the
basic approach is flawed.  As you say, it creates a fixed upper bound for the
number of threads the app may contain, creates visible gaps in the global
thread list (visible via getAll), and causes contention for a common cache
line.  However, I think it's reasonable to create some sort of thread id anyway,
if only to allow for thin locks to operate.  I've been kicking around a few ways
to graft this functionality onto Tango without incurring any undue overhead.


Sean



More information about the Digitalmars-d mailing list