# HG changeset patch # User Me # Date 1277933696 25200 # Node ID 8abcca1590b8bff7d99d0ae937b5c800524036b7 # Parent 09cfa875abbd5b5e5846438a2c747b2e624245b7 Tested and working on full VMS test diff -r 09cfa875abbd -r 8abcca1590b8 BlockingQueue.c --- a/BlockingQueue.c Wed Jun 30 13:10:49 2010 -0700 +++ b/BlockingQueue.c Wed Jun 30 14:34:56 2010 -0700 @@ -22,11 +22,11 @@ //=========================================================================== //Normal pthread Q -QueueStruc* makeQ() +PThdQueueStruc* makePThdQ() { - QueueStruc* retQ; + PThdQueueStruc* retQ; int status; - retQ = (QueueStruc *) malloc( sizeof( QueueStruc ) ); + retQ = (PThdQueueStruc *) malloc( sizeof( PThdQueueStruc ) ); status = pthread_mutex_init( &retQ->mutex_t, NULL); @@ -61,7 +61,7 @@ return retQ; } -void * readQ( QueueStruc *Q ) +void * readPThdQ( PThdQueueStruc *Q ) { void *ret; int status, wt; pthread_mutex_lock( &Q->mutex_t ); @@ -89,7 +89,7 @@ return( ret ); } -void writeQ( void * in, QueueStruc* Q ) +void writePThdQ( void * in, PThdQueueStruc* Q ) { int status, wt; pthread_mutex_lock( &Q->mutex_t ); @@ -152,9 +152,10 @@ int success = FALSE; - while( !success ) + while( TRUE ) { success = __sync_bool_compare_and_swap( &(Q->extractLock), UNLOCKED, LOCKED ); + //NOTE: checked assy, and it does lock correctly.. if( success ) { void **insertPos = Q->insertPos; @@ -195,7 +196,7 @@ int success = FALSE; - while( !success ) + while( TRUE ) { success = __sync_bool_compare_and_swap( &(Q->insertLock), UNLOCKED, LOCKED ); if( success ) @@ -208,7 +209,7 @@ if( extractPos - insertPos != 1 && !(insertPos == endOfData && extractPos == startOfData)) { *(Q->insertPos) = in; //insert before move - if( insertPos == endOfData ) //write new pos exactly once, correctly + if( insertPos == endOfData ) { Q->insertPos = startOfData; } else