Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread DarekM
Micha Nelissen pisze: DarekM wrote: Hi This is my proposition of algorithm and its implementing multithreaded FIFO queue without lock. Hmm 'Push' and 'Pop' sound like a stack, but the implementation seems to implement a FIFO indeed, with a head and tail. It should be enqueue and

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread Micha Nelissen
DarekM wrote: Hi This is my proposition of algorithm and its implementing multithreaded FIFO queue without lock. Hmm 'Push' and 'Pop' sound like a stack, but the implementation seems to implement a FIFO indeed, with a head and tail. You're sure about the situation where two threads are

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread Martin Friebe
What about a long running (eg daemon) application? If temp/tail hits the upper boundary of Integer? (If I understand it correctly) I don't know if interlockedIncrement gives a boundary error, but if not, it still fails. - With currently integer, it gets a negative value, once crossing

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread DarekM
Martin Friebe pisze: What about a long running (eg daemon) application? If temp/tail hits the upper boundary of Integer? (If I understand it correctly) I don't know if interlockedIncrement gives a boundary error, but if not, it still fails. - With currently integer, it gets a negative value,

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread DarekM
Martin Friebe pisze: You will need to test it, but the following may also work procedure tFlQueue.push(const tm : tNodeQueue); var newTemp, lastTail, newTail : integer; begin newTemp := temp; while newTemp = fsize begin // if it is true, every thread is going to attempt to fix it,

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread Florian Klaempfl
DarekM schrieb: Martin Friebe pisze: You will need to test it, but the following may also work procedure tFlQueue.push(const tm : tNodeQueue); var newTemp, lastTail, newTail : integer; begin newTemp := temp; while newTemp = fsize begin // if it is true, every thread is going to

interlocked commands [Re: [fpc-devel] LockFree Queue algorithm]

2008-01-27 Thread Martin Friebe
While watching this thread, I started to ask myself 2 questions (which may be related): They just came to mind a multi-core systems where mentioned, possible even systems with several CPUs. (Admiringly they are more looking like they should be on an intel-mailing list, I just hope someone may

[fpc-devel] Fpc Target directory function

2008-01-27 Thread L
Does a function like this exist: function FpcTargetDir: string; begin result:= {$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%}; end; Above works for my needs, just wonder if something already exists in RTL or if it should be added for convenience. ___

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread DarekM
Florian Klaempfl pisze: An if is unimportant, more important is the number of locked operations, especially on multi core systems they might eat hundreds of clock cycles. There are atomic operations, the should not eat much more than ordinal INC or ADD, and second CAS is invoked only one

Re: [fpc-devel] Fpc Target directory function

2008-01-27 Thread Peter Vreman
Does a function like this exist: function FpcTargetDir: string; begin result:= {$I %FPCTARGETCPU%}+'-'+{$I %FPCTARGETOS%}; end; Above works for my needs, just wonder if something already exists in RTL or if it should be added for convenience. It doesn't exists and i don't see a reason

Re: [fpc-devel] LockFree Queue algorithm

2008-01-27 Thread Florian Klaempfl
DarekM schrieb: Florian Klaempfl pisze: An if is unimportant, more important is the number of locked operations, especially on multi core systems they might eat hundreds of clock cycles. There are atomic operations, the should not eat much more than ordinal INC or ADD, If course they