Changeset 1095
- Timestamp:
- 08/25/06 02:43:26 (2 years ago)
- Location:
- sfio/trunk/src/lockfree
- Files:
-
- 4 modified
-
grame02_stack.c (modified) (4 diffs)
-
grame02_stack.h (modified) (3 diffs)
-
ms96_queue.c (modified) (5 diffs)
-
ms96_queue.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sfio/trunk/src/lockfree/grame02_stack.c
r1094 r1095 51 51 52 52 53 LIBLF _CALLING_CONVENTION(void) grame02_stack_initialize( grame02_stack_t* stack )53 LIBLFDS_CALLING_CONVENTION(void) grame02_stack_initialize( grame02_stack_t* stack ) 54 54 { 55 55 stack->top = 0; … … 57 57 58 58 59 LIBLF _CALLING_CONVENTION(void) grame02_stack_push( grame02_stack_t* stack, grame02_stack_node_t *node )59 LIBLFDS_CALLING_CONVENTION(void) grame02_stack_push( grame02_stack_t* stack, grame02_stack_node_t *node ) 60 60 { 61 61 // B1: loop … … 77 77 78 78 79 LIBLF _CALLING_CONVENTION(grame02_stack_node_t*) grame02_stack_pop( grame02_stack_t* stack )79 LIBLFDS_CALLING_CONVENTION(grame02_stack_node_t*) grame02_stack_pop( grame02_stack_t* stack ) 80 80 { 81 81 grame02_stack_node_t *top, *next; … … 110 110 111 111 112 LIBLF _CALLING_CONVENTION(void) grame02_stack_test(void)112 LIBLFDS_CALLING_CONVENTION(void) grame02_stack_test(void) 113 113 { 114 114 const char *s = "\n!dlrow olleh"; -
sfio/trunk/src/lockfree/grame02_stack.h
r1094 r1095 5 5 multiple-reader, multiple-writer lock-free LIFO stack 6 6 7 D. Fober, S. Letz, Y. Orlarey 8 Actes des Journées d'Informatique Musicale JIM2002, Marseille GMEM 2002 Pages 143--150. 9 ftp://ftp.grame.fr/pub/Documents/fober-JIM2002.pdf 7 D. Fober, S. Letz, Y. Orlarey 8 "Lock-Free Techniques for Concurrent Access to Shared Objects," 9 Actes des Journées d'Informatique Musicale JIM2002, Marseille GMEM 2002 Pages 143--150. 10 ftp://ftp.grame.fr/pub/Documents/fober-JIM2002.pdf 10 11 11 actually i think this is the IBMalgorithm, but I havn't found the reference yet12 actually i think this is the IBM freelist algorithm, but I havn't found the reference yet 12 13 */ 13 14 14 15 15 #define LIBLF _CALLING_CONVENTION( return_type ) return_type __stdcall16 #define LIBLFDS_CALLING_CONVENTION( return_type ) return_type __stdcall 16 17 17 18 #ifdef __cplusplus … … 21 22 22 23 23 typedef void* grame02_value_t; / / this is the "payload" data type which is stored in the stack node24 typedef void* grame02_value_t; /* this is the "payload" data type which is stored in the stack node */ 24 25 25 26 struct grame02_stack_node_t; … … 44 45 45 46 46 LIBLF _CALLING_CONVENTION(void) grame02_stack_initialize( grame02_stack_t* stack );47 LIBLFDS_CALLING_CONVENTION(void) grame02_stack_initialize( grame02_stack_t* stack ); 47 48 48 LIBLF _CALLING_CONVENTION(void) grame02_stack_push( grame02_stack_t* stack, grame02_stack_node_t *node );49 LIBLFDS_CALLING_CONVENTION(void) grame02_stack_push( grame02_stack_t* stack, grame02_stack_node_t *node ); 49 50 50 LIBLF _CALLING_CONVENTION(grame02_stack_node_t*) grame02_stack_pop( grame02_stack_t* stack );51 LIBLFDS_CALLING_CONVENTION(grame02_stack_node_t*) grame02_stack_pop( grame02_stack_t* stack ); 51 52 52 LIBLF _CALLING_CONVENTION(void) grame02_stack_test(void);53 LIBLFDS_CALLING_CONVENTION(void) grame02_stack_test(void); 53 54 54 55 #ifdef __cplusplus -
sfio/trunk/src/lockfree/ms96_queue.c
r1094 r1095 118 118 119 119 120 LIBLF _CALLING_CONVENTION(void) ms96_queue_initialize( ms96_queue_t *q, ms96_queue_node_t* node )120 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_initialize( ms96_queue_t *q, ms96_queue_node_t* node ) 121 121 { 122 122 // node = new node() # Allocate a free node … … 140 140 141 141 142 LIBLF _CALLING_CONVENTION(void) ms96_queue_terminate( ms96_queue_t* queue, ms96_queue_node_t** node )142 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_terminate( ms96_queue_t* queue, ms96_queue_node_t** node ) 143 143 { 144 144 assert_empty( queue ); … … 149 149 150 150 // enqueue(Q: pointer to queue t, value: data type) 151 LIBLF _CALLING_CONVENTION(void) ms96_queue_enqueue( ms96_queue_t* q, ms96_queue_node_t *node, ms96_value_t value )151 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_enqueue( ms96_queue_t* q, ms96_queue_node_t *node, ms96_value_t value ) 152 152 { 153 153 ms96_tagged_node_pointer_t tail; … … 210 210 211 211 // dequeue(Q: pointer to queue t, pvalue: pointer to data type): boolean 212 LIBLF _CALLING_CONVENTION(int) ms96_queue_dequeue( ms96_queue_t* q, ms96_queue_node_t** node, ms96_value_t* value )212 LIBLFDS_CALLING_CONVENTION(int) ms96_queue_dequeue( ms96_queue_t* q, ms96_queue_node_t** node, ms96_value_t* value ) 213 213 { 214 214 ms96_tagged_node_pointer_t head; … … 279 279 280 280 281 LIBLF _CALLING_CONVENTION(void) ms96_queue_test(void)281 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_test(void) 282 282 { 283 283 const char *s = "hello world!\n"; -
sfio/trunk/src/lockfree/ms96_queue.h
r1094 r1095 5 5 multiple-reader, multiple-writer lock-free FIFO queue 6 6 7 8 Michael, M. M. and Scott, M. L., 9 "Simple, fast and practical non-blocking and blocking concurrent queue algorithms," 10 Proceedings of the 15th Annual ACM Symposium on Principles of Distributed 11 Computing (PODC), pp. 267--275, May 1996. 12 http://citeseer.ist.psu.edu/michael96simple.html 7 Michael, M. M. and Scott, M. L., 8 "Simple, fast and practical non-blocking and blocking concurrent queue algorithms," 9 Proceedings of the 15th Annual ACM Symposium on Principles of Distributed 10 Computing (PODC), pp. 267--275, May 1996. 11 http://citeseer.ist.psu.edu/michael96simple.html 13 12 */ 14 13 15 #define LIBLF _CALLING_CONVENTION( return_type ) return_type __stdcall14 #define LIBLFDS_CALLING_CONVENTION( return_type ) return_type __stdcall 16 15 17 16 … … 21 20 #endif /* __cplusplus */ 22 21 23 typedef void* ms96_value_t; // this is the "payload" data type which is stored in the queue node 24 // the algorithm allows this to be anything, but at present (at least) 25 // we don't allow it to be (perhaps in future we could pass a special 26 // copy function to support other data types. 22 typedef void* ms96_value_t; /* this is the "payload" data type which is stored in the queue node 23 the algorithm allows this to be anything, but at present (at least) 24 we don't allow it to be (perhaps in future we could pass a special 25 copy function to support other data types) 26 */ 27 27 28 28 struct ms96_queue_node_t; … … 53 53 54 54 55 // initialize queue, requires a node 56 LIBLF_CALLING_CONVENTION(void) ms96_queue_initialize( ms96_queue_t* queue, ms96_queue_node_t* node ); 55 /* initialize queue, requires a node 56 */ 57 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_initialize( ms96_queue_t* queue, ms96_queue_node_t* node ); 57 58 58 // deinitialize queue, expects queue to be empty and to stay that way 59 // returns a node 60 LIBLF_CALLING_CONVENTION(void) ms96_queue_terminate( ms96_queue_t* queue, ms96_queue_node_t** node ); 59 /* deinitialize queue, expects queue to be empty and to stay that way 60 return the dummy link node used by the queue 61 */ 62 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_terminate( ms96_queue_t* queue, ms96_queue_node_t** node ); 61 63 62 64 63 // to engueue, supply a node (allocated from somewhere), and a value 64 // algorithm constraints: nodes must never be freed to the system, or unmapped 65 // from memory once they've been passed to enqueue. (not sure if there's also 66 // a memory class contraint here). 67 LIBLF_CALLING_CONVENTION(void) ms96_queue_enqueue( ms96_queue_t* queue, ms96_queue_node_t* node, ms96_value_t value ); 65 /* to enqueue, supply a node (allocated from somewhere), and a value 66 algorithm constraints: nodes must never be freed to the system, or unmapped 67 from memory once they've been passed to enqueue. (not sure if there's also 68 a memory class contraint here). 69 */ 70 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_enqueue( ms96_queue_t* queue, ms96_queue_node_t* node, ms96_value_t value ); 68 71 69 // dequeue returns a node, and the value 70 // returns non-zero on success 71 LIBLF_CALLING_CONVENTION(int) ms96_queue_dequeue( ms96_queue_t* queue, ms96_queue_node_t** node, ms96_value_t* value ); 72 /* dequeue returns a node, and the value 73 returns non-zero on success, zero if the queue was empty 74 */ 75 LIBLFDS_CALLING_CONVENTION(int) ms96_queue_dequeue( ms96_queue_t* queue, ms96_queue_node_t** node, ms96_value_t* value ); 72 76 73 LIBLF _CALLING_CONVENTION(void) ms96_queue_test(void);77 LIBLFDS_CALLING_CONVENTION(void) ms96_queue_test(void); 74 78 75 79
