Search the web
Sign In
New User? Sign Up
liblf-dev · Lockfree data structure implementers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
an implementation of lock-free queue without atomic   Message List  
Reply | Forward Message #292 of 300 |
I have an idea about lock-free queue without atomic , you can find source code
at http://code.google.com/p/liblfqueue/downloads/list . Any body can send email
to romandion@... . I list the code below and wish your help .

typedef struct _qnode_st qnode_t ;
struct _qnode_st{
qnode_t *next ;
} ;

#define MAX_RING_SIZE 3
typedef struct _queue_st queue_t ;
struct _queue_st{
qnode_t *nodes[MAX_RING_SIZE] ;

int enqueue ;
int dequeue ;

qnode_t *enlast ;
} ;

int enqueue(queue_t *queue , qnode_t *node)
{
int old = queue->enqueue ;
node->next = NULL ;

if(queue->nodes[old] == NULL)
{
queue->enlast = node ;
queue->enqueue++ ;
if(queue->enqueue >= MAX_RING_SIZE)
queue->enqueue = 0 ;
queue->nodes[old] = node ;
}
else
{
queue->enlast->next = node ;
queue->enlast = node ;
}

return 0 ;
}

qnode_t *dequeue(queue_t *queue)
{
int old = queue->dequeue ;
qnode_t *tmp ;

if(queue->nodes[old] == NULL)
return NULL ;

tmp = queue->nodes[old] ;
queue->nodes[old] = tmp->next ;
if(tmp->next == NULL)
{
old++ ;
if(old >= MAX_RING_SIZE)
old = 0 ;
queue->dequeue = old ;
}

return tmp ;
}




Thu Mar 26, 2009 8:12 am

romandion78
Offline Offline
Send Email Send Email

Forward
Message #292 of 300 |
Expand Messages Author Sort by Date

I have an idea about lock-free queue without atomic , you can find source code at http://code.google.com/p/liblfqueue/downloads/list . Any body can send email...
romandion78
Offline Send Email
Mar 26, 2009
8:59 am

There don't appear to be any memory barriers in your code. How are you avoiding the issue of out-of-order execution on multiprocessor machines? Chris...
Chris Purcell
c_purcell_39
Offline Send Email
Mar 26, 2009
11:13 am

... Thank you , Chris . Sorry for my poor english , I will try my best to express my own opinion . It is true that I don't use any memory barriers in my...
romandion78
Offline Send Email
Mar 31, 2009
7:29 am

I'm very sorry that I can not find my posted reply in this groups , this is third time .why ? ... Thank you , Chris . Sorry for my poor english , I will try...
Roman Dion
romandion78
Offline Send Email
Mar 31, 2009
7:29 am

The issue that concerns me is the ordering of memory operations on the node pointer and on the node itself. For instance, the write of the node's address to...
Chris Purcell
c_purcell_39
Offline Send Email
Mar 31, 2009
6:05 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help