Page 1 of 1

Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 3:56 am
by Pype.Clicker
An article i've found in Dr Dobb's Journal: "Lock-free Interprocess Communication". I haven't read it in detail but it sounds appealing.

Just wanted to report it to MT (and see your reaction about it ;) )

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 7:30 am
by Pype.Clicker
just got a deeper look and, quite frankly, i'm disappointed. What the guy calls "lock-free IPC" is merely

Code: Select all

do {
   while (shared_memory[i]==0) doSomethingUseful();
   ConsumeWord(shared_memory[i]);
   i++;
}
so yes ... it's lock free ... but it will only do good job if you have actually "something useful" to do and have more CPUs than threads involved into the "chain of communication".

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 7:40 am
by Colonel Kernel
I haven't read the article yet, but there is a lock-free implementation of IPC in Singularity. The catch of course is that its safety relies on certain guarantees made by the compiler regarding how IPC channels can be used.

Language Support for Fast and Reliable Message-based Communication in Singularity OS

I'll read the article now... :)

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 8:10 am
by Pype.Clicker
nice article too, though it doesn't seem to be on the same topic at all, as far as i can tell.

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 8:48 am
by Colonel Kernel
Exactly. Isn't that why you were disappointed with the DDJ article (because it wasn't about implementing general-purpose IPC in an OS)? :)

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 8:53 am
by Solar
Pype.Clicker wrote: ...it will only do good job if you have actually "something useful" to do and have more CPUs than threads involved into the "chain of communication".
But... but... aren't we all going to use 100-CPU multicore systems any day now? :o ;D

(Oh yes, it's so easy to ignore algorithm issues and let the hardware progression solve them... hello Windows. 8) )

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 9:11 am
by Pype.Clicker
Colonel Kernel wrote: Exactly. Isn't that why you were disappointed with the DDJ article
no. More because i expected it to present some kind of "new" technique for IPCs and it just appeared to be a old technique you've shown in CS courses to illustrate the need for synchronizing atomic functions in an OS (in order to avoid time wasted in polling loops).

Re:Lock-free IPC (seen in DDJ)

Posted: Mon Jun 26, 2006 9:49 am
by Candy
lockfree IPC: use locked bus transactions. They're atomical by nature. Okay, locked bus transactions aren't actually lock-free but at least they don't lock much.

Hm... Thinking of it, lock-free is impossible by definition, except in cases where you use them rather as deferred cothreads. Using an OS that has a yield_to(xyz) function allows that, you allocate space for one item, produce one item and store it, then if it is full, you yield to the consumer(s). Dito for consumers, when it's empty, you yield to the producer. Assuming quick thread switches, this is darn fast.