Search the web
Sign In
New User? Sign Up
liblf-dev · Lockfree data structure implementers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
question on lock-free message passing, is it possible?   Message List  
Reply | Forward Message #275 of 300 |
Hello,

This seemed like an appropriate place for this question.

This is quite random, but I am emailing because I was wondering if I
could get your opinion on a problem I am facing. I have been
developing real-time simulation (VR) software. I don't currently know
any professors who are experts on this issue so I
am looking for an outside opinion. I'll just pose the question and
you can ignore me if you like. :)

This software is multi-threaded, and I'm trying to take advantage of
asynchronous threads as much as possible by running several
simultaneous simulations (one doing graphics, one doing haptics, one
doing physics) and while I'm currently using a slow method of
communication between my threads so as to avoid locking my data
structures (which would force synchroneity), I'm looking to improve it
by taking advantage of shared memory for message passing. Each thread
is considered soft real-time so they cannot block.

My plan is to do this using the test-and-set atomic operation (using
the HP atomic_ops library). I have implemented the basic mechanism.
Without describing everything in detail, basically message slots in a
buffer are marked as in-use or not, as well as empty or non-empty,
using test-and-set. The threads step through the queue looking for
unused slots. The write operation then looks for empty slots and
'allocates' them, using test-and-swap. The read operation marks a
slot as in-use before checking the message, then marking it empty
after acting.

Anyways, I have received some criticism: "the authors claim that
shared memory message-passing implementations using atomic
test-and-set are 'lock-free'. This seems self-contradictory, as the
whole purpose of test-and-set ops are to implement locks efficiently
and robustly."

So, my question is, is this criticism correct? I never claimed that
all message-passing implementations were lock free, only that I was
developing a lock free message passing implementation. But I don't
know if this person knows something I don't, and it's anonymous so I
can't ask them.

I think that I've successfully implemented a message passing system
which is free of locks, taking advantage of the fact that my threads
are free to be asynchronous and so don't need to wait on each other
but can just place messages in the queue. The atomic operations are
simple, but sufficient to ensure that slots are not simultaneously
used by multiple threads. Certainly my code doesn't implement any
spinlocks or use pthread mutexes. Can I honestly say that I have
implemented a lock free implementation, or is there something hidden
in the atomic_ops library that does something contradicting my claim?

Also, do you have any knowledge of other lock-free message passing
implementations, making use of atomic ops or not?

Thanks for any help you can offer. By the way, somewhat more
on-topic, in the code I am talking about the message passing stuff is
being implemented as a separate library and is GPL. It's available
and seems to work okay, but I'll publish the URL when it's more ready.
One issue I've had is that writing unit tests for the code is quite
difficult since I don't know what to check for to see if any errors
occurred. (Other than a segfault of course.)


Steve



Fri Sep 26, 2008 3:38 am

sinclairs828
Offline Offline
Send Email Send Email

Forward
Message #275 of 300 |
Expand Messages Author Sort by Date

Hello, This seemed like an appropriate place for this question. This is quite random, but I am emailing because I was wondering if I could get your opinion on...
Stephen Sinclair
sinclairs828
Offline Send Email
Sep 26, 2008
4:05 am

You could use the terminology 'wait-free' instead to transcend the issue? Though it seems that your reviewer is wrongfully assigning purpose of TAS to locks,...
Graham Wakefield
mbirambira
Offline Send Email
Sep 28, 2008
4:32 am

On Fri, Sep 26, 2008 at 2:12 PM, Graham Wakefield ... Yes, I only read recently that there is a subtle difference in the semantics of wait-free and lock-free....
Stephen Sinclair
sinclairs828
Offline Send Email
Sep 29, 2008
3:03 am

I suggest reading http://en.wikipedia.org/wiki/Non-blocking_synchronization Chris...
Chris Purcell
c_purcell_39
Offline Send Email
Sep 29, 2008
7:48 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help