Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #958

About lockfree_mpmc -

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "aminer" <aminer@videotron.ca>
Newsgroups comp.programming.threads, comp.programming
Subject About lockfree_mpmc -
Date Sun, 22 Jul 2012 18:27:09 -0500
Organization A noiseless patient Spider
Lines 72
Message-ID <juhuo3$q5s$1@dont-email.me> (permalink)
Injection-Date Sun, 22 Jul 2012 22:27:15 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="c43ca82f9e8d62a602307fe9d2e9b807"; logging-data="26812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IpIqPoXf3UNp7JdQxvjmt"
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.5512
X-Newsreader Microsoft Outlook Express 6.00.2900.5512
Cancel-Lock sha1:1tk1DruFP5zez+XMzFSXwgOM5WE=
X-Priority 3
X-MSMail-Priority Normal
X-Rfc2646 Format=Flowed; Original
Xref csiph.com comp.programming.threads:958 comp.programming:1994

Cross-posted to 2 groups.

Show key headers only | View raw


Hello all,

I think i have discovered a problem with lockfree_mpmc:

You will find the source code of lockfree_mpmc at:

http://pages.videotron.com/aminer/


So please follow with me:

If you take a look at the lockfree_mpmc , here is  the source code
of the push() method:

---

function TLockfree_MPMC.push(tm : tNodeQueue):boolean;
var lasttail,newtemp:long;
i,j:integer;
begin

 if getlength >= fsize
  then
      begin
          result:=false;
          exit;
      end;
result:=true;

newTemp:=LockedIncLong(temp);

[1] lastTail:=newTemp-1;
[2] setObject(lastTail,tm);

repeat

 if CAS(tail,lasttail,newtemp)
   then
      begin
       exit;
      end;
sleep(0);
 until false;

end;

---

As you know in the x86 architecture Loads may be reordered with older stores
to different locations.

So in line [2] there is a load of tail and lasttail to the registers of the 
processor
before calling setobject() and just before on line [1] there is a store to 
lasttail.

So as you have noticed the processor can then reorder the loads on line [2] 
with the older
store on line [1] and this will cause a problem, so i think i have to insert 
a load between
line [1] and line [2].


What do you think ?



Sincerely,
Amine Moulay Ramdane.

Back to comp.programming.threads | Previous | NextNext in thread | Find similar


Thread

About lockfree_mpmc - "aminer" <aminer@videotron.ca> - 2012-07-22 18:27 -0500
  Re: About lockfree_mpmc - "aminer" <aminer@videotron.ca> - 2012-07-22 18:34 -0500
    Re: About lockfree_mpmc - "aminer" <aminer@videotron.ca> - 2012-07-22 18:51 -0500

csiph-web