Thread View: borland.public.delphi.language.basm
1 messages
1 total messages
Started by aminer
Thu, 15 Dec 2011 16:32
Can you tranlate the following pseudocode to delphi and basm ?
Author: aminer
Date: Thu, 15 Dec 2011 16:32
Date: Thu, 15 Dec 2011 16:32
70 lines
2769 bytes
2769 bytes
Hello,
I have found the following pseudo code of a very efficient fifo queue
that doen't use any CAS
just an XADD , and i want to ask you if someone can translate it to
Delphi and basm .
Here it is:
pseudo-code for a mpmc bounded queue of doubles:
______________________________________________
struct cell { uint32_t ver; double state; };
uint32_t head = 0;
uint32_t tail = 0;
cell cells[N]; // N must be a power of 2
void init() {
for (uint32_t i = 0; i < N; ++i) cells.ver = i;
}
void producer(double state) {
uint32_t ver = XADD(&head, 1);
cell& c = cells[ver & (N - 1)];
while (LOAD(&c.ver) != ver) backoff();
c.state = state;
STORE(&c.ver, ver + 1);
}
double consumer() {
uint32_t ver = XADD(&tail, 1);
cell& c = cells[ver & (N - 1)];
while (LOAD(&c.ver) != ver + 1) backoff();
double state = c.state;
STORE(&c.ver, ver + N);
return state;
}
______________________________________________
And here is the link it's by invented by:
Chris M. Thomasson
here is his message on usenet on the following forum:
comp.programming.threads
http://groups.google.com/group/comp.programming.threads/browse_thread/thread/f9cab03871241455#
Best regards,
Amine Moulay Ramdane.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads