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


Groups > comp.programming > #1994 > unrolled thread

About lockfree_mpmc -

Started by"aminer" <aminer@videotron.ca>
First post2012-07-22 18:27 -0500
Last post2012-07-22 18:51 -0500
Articles 3 — 1 participant

Back to article view | Back to comp.programming


Contents

  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

#1994 — About lockfree_mpmc -

From"aminer" <aminer@videotron.ca>
Date2012-07-22 18:27 -0500
SubjectAbout lockfree_mpmc -
Message-ID<juhuo3$q5s$1@dont-email.me>
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.

[toc] | [next] | [standalone]


#1995

From"aminer" <aminer@videotron.ca>
Date2012-07-22 18:34 -0500
Message-ID<juhv62$sda$1@dont-email.me>
In reply to#1994
I wrote:
> 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].


Even if i insert a load beween line [1] and [2] this will not work ,
i have to insert an mfence between line [1] and [2].


What do you think ?


Sincerely,
Amine Moulay Ramdane.






"aminer" <aminer@videotron.ca> wrote in message 
news:juhuo3$q5s$1@dont-email.me...
>
> 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.
>
> 

[toc] | [prev] | [next] | [standalone]


#1996

From"aminer" <aminer@videotron.ca>
Date2012-07-22 18:51 -0500
Message-ID<jui06e$1pa$1@dont-email.me>
In reply to#1995
Hello,

I have inserted an mfence between line [1] and [2] in lockfree_mpmc and i 
have
updated all my programs that uses lockfree_mpmc, and you can download all
the source codes of my programs from:

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



Sincerely,
Amine Moulay Ramdane.





"aminer" <aminer@videotron.ca> wrote in message 
news:juhv62$sda$1@dont-email.me...
>
> I wrote:
>> 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].
>
>
> Even if i insert a load beween line [1] and [2] this will not work ,
> i have to insert an mfence between line [1] and [2].
>
>
> What do you think ?
>
>
> Sincerely,
> Amine Moulay Ramdane.
>
>
>
>
>
>
> "aminer" <aminer@videotron.ca> wrote in message 
> news:juhuo3$q5s$1@dont-email.me...
>>
>> 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.
>>
>>
>
> 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming


csiph-web