changeset 20:b5ae7fbb1f01 MC_shared

Created MC_shared brch
author Me@portablequad
date Sat, 11 Feb 2012 20:37:52 -0800
parents 1ed562d601d9
children 59781a4c9cf1
files .brch__MC_shared .hgeol BlockingQueue.c BlockingQueue.h PrivateQueue.c PrivateQueue.h
diffstat 6 files changed, 35 insertions(+), 96 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.brch__MC_shared	Sat Feb 11 20:37:52 2012 -0800
     1.3 @@ -0,0 +1,4 @@
     1.4 +This branch is for the project structure defined Jan 2012..  the #includes reflect this directory structure.
     1.5 +
     1.6 +More importantly, the MC_shared  version of VMS requires a separat malloc implemeted by VMS code..  so this branch has modified the library to use the VMS-specific malloc.
     1.7 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/.hgeol	Sat Feb 11 20:37:52 2012 -0800
     2.3 @@ -0,0 +1,14 @@
     2.4 +
     2.5 +[patterns]
     2.6 +**.py = native
     2.7 +**.txt = native
     2.8 +**.c = native
     2.9 +**.h = native
    2.10 +**.cpp = native
    2.11 +**.java = native
    2.12 +**.class = bin
    2.13 +**.jar = bin
    2.14 +**.sh = native
    2.15 +**.pl = native
    2.16 +**.jpg = bin
    2.17 +**.gif = bin
     3.1 --- a/BlockingQueue.c	Tue Feb 07 12:51:29 2012 -0800
     3.2 +++ b/BlockingQueue.c	Sat Feb 11 20:37:52 2012 -0800
     3.3 @@ -18,89 +18,6 @@
     3.4  
     3.5  #define SPINLOCK_TRIES 100000
     3.6  
     3.7 -//===========================================================================
     3.8 -//Normal pthread Q
     3.9 -
    3.10 -PThdQueueStruc* makePThdQ()
    3.11 - {
    3.12 -   PThdQueueStruc* retQ;
    3.13 -   int retCode;
    3.14 -   retQ = (PThdQueueStruc *) malloc( sizeof( PThdQueueStruc ) );
    3.15 -
    3.16 -
    3.17 -   retCode =
    3.18 -   pthread_mutex_init( &retQ->mutex_t,  NULL);
    3.19 -   if(retCode){perror("Error in creating mutex:"); exit(1);}
    3.20 -
    3.21 -   retCode = pthread_cond_init ( &retQ->cond_w_t, NULL);
    3.22 -   if(retCode){perror("Error in creating cond_var:"); exit(1);}
    3.23 -
    3.24 -   retCode = pthread_cond_init ( &retQ->cond_r_t, NULL);
    3.25 -   if(retCode){perror("Error in creating cond_var:"); exit(1);}
    3.26 -
    3.27 -   retQ->count    = 0;
    3.28 -   retQ->readPos  = 0;
    3.29 -   retQ->writePos = 0;
    3.30 -   retQ->w_empty  = 0;
    3.31 -   retQ->w_full   = 0;
    3.32 -
    3.33 -   return retQ;
    3.34 - }
    3.35 -
    3.36 -void * readPThdQ( PThdQueueStruc *Q )
    3.37 - { void *ret;
    3.38 -   int retCode, wt;
    3.39 -   pthread_mutex_lock( &Q->mutex_t );
    3.40 -    {
    3.41 -      while( Q -> count == 0 )
    3.42 -       { Q -> w_empty = 1;
    3.43 -         retCode =
    3.44 -         pthread_cond_wait( &Q->cond_r_t, &Q->mutex_t );
    3.45 -         if( retCode ){ perror("Thread wait error: "); exit(1); }
    3.46 -       }
    3.47 -      Q -> w_empty = 0;
    3.48 -      Q -> count -= 1;
    3.49 -      ret = Q->data[ Q->readPos ];
    3.50 -      INC( Q->readPos );
    3.51 -      wt = Q -> w_full;
    3.52 -      Q -> w_full = 0;
    3.53 -    }
    3.54 -   pthread_mutex_unlock( &Q->mutex_t );
    3.55 -   if (wt)
    3.56 -      pthread_cond_signal( &Q->cond_w_t );
    3.57 -
    3.58 -         //printf("Q out: %d\n", ret);
    3.59 -   return( ret );
    3.60 - }
    3.61 -
    3.62 -void writePThdQ( void * in, PThdQueueStruc* Q )
    3.63 - {
    3.64 -   int status, wt;
    3.65 -         //printf("Q in: %d\n", in);
    3.66 -
    3.67 -   pthread_mutex_lock( &Q->mutex_t );
    3.68 -    {
    3.69 -      while( Q->count >= 1024 )
    3.70 -       {
    3.71 -         Q -> w_full = 1;
    3.72 -         status = pthread_cond_wait( &Q->cond_w_t, &Q->mutex_t );
    3.73 -         if (status != 0)
    3.74 -          { perror("Thread wait error: ");
    3.75 -            exit(1);
    3.76 -          }
    3.77 -       }
    3.78 -
    3.79 -      Q -> w_full = 0;
    3.80 -      Q->count += 1;
    3.81 -      Q->data[ Q->writePos ] = in;
    3.82 -      INC( Q->writePos );
    3.83 -      wt = Q -> w_empty;
    3.84 -      Q -> w_empty = 0;
    3.85 -    }
    3.86 -
    3.87 -   pthread_mutex_unlock( &Q->mutex_t );
    3.88 -   if( wt )  pthread_cond_signal( &Q->cond_r_t );
    3.89 - }
    3.90  
    3.91  
    3.92  //===========================================================================
    3.93 @@ -117,7 +34,7 @@
    3.94  CASQueueStruc* makeCASQ()
    3.95   {
    3.96     CASQueueStruc* retQ;
    3.97 -   retQ = (CASQueueStruc *) malloc( sizeof( CASQueueStruc ) );
    3.98 +   retQ = (CASQueueStruc *) VMS__malloc( sizeof( CASQueueStruc ) );
    3.99  
   3.100     retQ->insertLock = UNLOCKED;
   3.101     retQ->extractLock= UNLOCKED;
   3.102 @@ -242,7 +159,7 @@
   3.103  SRSWQueueStruc* makeSRSWQ()
   3.104   {
   3.105     SRSWQueueStruc* retQ;
   3.106 -   retQ = (SRSWQueueStruc *) malloc( sizeof( SRSWQueueStruc ) );
   3.107 +   retQ = (SRSWQueueStruc *) VMS__malloc( sizeof( SRSWQueueStruc ) );
   3.108     memset( retQ->startOfData, 0, 1024 * sizeof(void *) );
   3.109     
   3.110     retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty
   3.111 @@ -255,7 +172,7 @@
   3.112  void
   3.113  freeSRSWQ( SRSWQueueStruc* Q )
   3.114   {
   3.115 -   free( Q );
   3.116 +   VMS__free( Q );
   3.117   }
   3.118  
   3.119  void* readSRSWQ( SRSWQueueStruc* Q )
   3.120 @@ -381,11 +298,11 @@
   3.121  SRMWQueueStruc* makeSRMWQ()
   3.122   { SRMWQueueStruc* retQ;
   3.123     
   3.124 -   retQ = (SRMWQueueStruc *) malloc( sizeof( SRMWQueueStruc ) );
   3.125 +   retQ = (SRMWQueueStruc *) VMS__malloc( sizeof( SRMWQueueStruc ) );
   3.126     
   3.127     retQ->numInternalQs = 0;
   3.128     retQ->internalQsSz  = 10;
   3.129 -   retQ->internalQs = malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *));
   3.130 +   retQ->internalQs = VMS__malloc( retQ->internalQsSz * sizeof(SRSWQueueStruc *));
   3.131     
   3.132     retQ->lastQReadFrom = 0;
   3.133     
   3.134 @@ -411,11 +328,11 @@
   3.135        oldSz            = Q->internalQsSz;
   3.136        oldArray         = Q->internalQs;
   3.137        Q->internalQsSz *= 2;
   3.138 -      Q->internalQs    = malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *));
   3.139 +      Q->internalQs    = VMS__malloc( Q->internalQsSz * sizeof(SRSWQueueStruc *));
   3.140        for( i = 0; i < oldSz; i++ )
   3.141         { Q->internalQs[i] = oldArray[i];
   3.142         }
   3.143 -      free( oldArray );
   3.144 +      VMS__free( oldArray );
   3.145      }
   3.146     Q->internalQs[ Q->numInternalQs - 1 ] = makeSRSWQ();
   3.147     return Q->numInternalQs - 1;
     4.1 --- a/BlockingQueue.h	Tue Feb 07 12:51:29 2012 -0800
     4.2 +++ b/BlockingQueue.h	Sat Feb 11 20:37:52 2012 -0800
     4.3 @@ -8,7 +8,8 @@
     4.4  #ifndef _BLOCKINGQUEUE_H
     4.5  #define	_BLOCKINGQUEUE_H
     4.6  
     4.7 -#include "pthread.h"
     4.8 +#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
     4.9 +#include "../../VMS_Implementations/VMS_impl/vmalloc.h"
    4.10  
    4.11  
    4.12  #define TRUE  1
     5.1 --- a/PrivateQueue.c	Tue Feb 07 12:51:29 2012 -0800
     5.2 +++ b/PrivateQueue.c	Sat Feb 11 20:37:52 2012 -0800
     5.3 @@ -26,9 +26,9 @@
     5.4  PrivQueueStruc* makePrivQ()
     5.5   {
     5.6     PrivQueueStruc* retQ;
     5.7 -   retQ = (PrivQueueStruc *) malloc( sizeof( PrivQueueStruc ) );
     5.8 +   retQ = (PrivQueueStruc *) VMS__malloc( sizeof( PrivQueueStruc ) );
     5.9  
    5.10 -   retQ->startOfData = malloc( 1024 * sizeof(void *) );
    5.11 +   retQ->startOfData = VMS__malloc( 1024 * sizeof(void *) );
    5.12     memset( retQ->startOfData, 0, 1024 * sizeof(void *) );
    5.13     retQ->extractPos = &(retQ->startOfData[0]); //side by side == empty
    5.14     retQ->insertPos  = &(retQ->startOfData[1]); // so start pos's have to be
    5.15 @@ -46,9 +46,9 @@
    5.16     oldSize           = Q->endOfData - Q->startOfData;
    5.17     newSize           = 2 * oldSize;
    5.18     oldStartOfData = Q->startOfData;
    5.19 -   Q->startOfData = malloc( newSize * sizeof(void *) );
    5.20 +   Q->startOfData = VMS__malloc( newSize * sizeof(void *) );
    5.21     memcpy(Q->startOfData, oldStartOfData, oldSize * sizeof(void *));
    5.22 -   free(oldStartOfData);
    5.23 +   VMS__free(oldStartOfData);
    5.24     
    5.25     Q->extractPos  = &(Q->startOfData[0]); //side by side == empty
    5.26     Q->insertPos   = &(Q->startOfData[1]); // so start pos's have to be
     6.1 --- a/PrivateQueue.h	Tue Feb 07 12:51:29 2012 -0800
     6.2 +++ b/PrivateQueue.h	Sat Feb 11 20:37:52 2012 -0800
     6.3 @@ -8,7 +8,10 @@
     6.4  #ifndef _PRIVATE_QUEUE_H
     6.5  #define	_PRIVATE_QUEUE_H
     6.6  
     6.7 -#include <pthread.h>
     6.8 +
     6.9 +#include "../../VMS_Implementations/VMS_impl/VMS_primitive_data_types.h"
    6.10 +#include "../../VMS_Implementations/VMS_impl/vmalloc.h"
    6.11 +
    6.12  
    6.13  #define TRUE     1
    6.14  #define FALSE    0