changeset 4:8abcca1590b8

Tested and working on full VMS test
author Me
date Wed, 30 Jun 2010 14:34:56 -0700
parents 09cfa875abbd
children 228ca5487d81
files BlockingQueue.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line diff
     1.1 --- a/BlockingQueue.c	Wed Jun 30 13:10:49 2010 -0700
     1.2 +++ b/BlockingQueue.c	Wed Jun 30 14:34:56 2010 -0700
     1.3 @@ -22,11 +22,11 @@
     1.4  //===========================================================================
     1.5  //Normal pthread Q
     1.6  
     1.7 -QueueStruc* makeQ()
     1.8 +PThdQueueStruc* makePThdQ()
     1.9   {
    1.10 -   QueueStruc* retQ;
    1.11 +   PThdQueueStruc* retQ;
    1.12     int status;
    1.13 -   retQ = (QueueStruc *) malloc( sizeof( QueueStruc ) );
    1.14 +   retQ = (PThdQueueStruc *) malloc( sizeof( PThdQueueStruc ) );
    1.15  
    1.16  
    1.17     status = pthread_mutex_init( &retQ->mutex_t,  NULL);
    1.18 @@ -61,7 +61,7 @@
    1.19     return retQ;
    1.20   }
    1.21  
    1.22 -void * readQ( QueueStruc *Q )
    1.23 +void * readPThdQ( PThdQueueStruc *Q )
    1.24   { void *ret;
    1.25     int status, wt;
    1.26     pthread_mutex_lock( &Q->mutex_t );
    1.27 @@ -89,7 +89,7 @@
    1.28     return( ret );
    1.29   }
    1.30  
    1.31 -void writeQ( void * in, QueueStruc* Q )
    1.32 +void writePThdQ( void * in, PThdQueueStruc* Q )
    1.33   {
    1.34     int status, wt;
    1.35     pthread_mutex_lock( &Q->mutex_t );
    1.36 @@ -152,9 +152,10 @@
    1.37  
    1.38     int  success = FALSE;
    1.39  
    1.40 -   while( !success )
    1.41 +   while( TRUE )
    1.42      { success =
    1.43           __sync_bool_compare_and_swap( &(Q->extractLock), UNLOCKED, LOCKED );
    1.44 +            //NOTE: checked assy, and it does lock correctly..
    1.45        if( success )
    1.46         {
    1.47           void **insertPos  = Q->insertPos;
    1.48 @@ -195,7 +196,7 @@
    1.49  
    1.50     int  success = FALSE;
    1.51  
    1.52 -   while( !success )
    1.53 +   while( TRUE )
    1.54      { success =
    1.55           __sync_bool_compare_and_swap( &(Q->insertLock), UNLOCKED, LOCKED );
    1.56        if( success )
    1.57 @@ -208,7 +209,7 @@
    1.58           if( extractPos - insertPos != 1 &&
    1.59               !(insertPos == endOfData && extractPos == startOfData))
    1.60            { *(Q->insertPos) = in;   //insert before move
    1.61 -            if( insertPos == endOfData ) //write new pos exactly once, correctly
    1.62 +            if( insertPos == endOfData )
    1.63               { Q->insertPos = startOfData;
    1.64               }
    1.65              else