28 #ifdef ABC_USE_PTHREADS 
   31 #include "../lib/pthread.h" 
   45 #ifndef ABC_USE_PTHREADS 
   47 void Cmd_RunStarter( 
char * pFileName, 
char * pBinary, 
char * pCommand, 
int nCores ) {}
 
   49 #else // pthreads are used 
   55 pthread_mutex_t 
mutex = PTHREAD_MUTEX_INITIALIZER;
 
   76     if ( 
system( (
char *)pCommand ) )
 
   78         fprintf( stderr, 
"The following command has returned non-zero exit status:\n" );
 
   79         fprintf( stderr, 
"\"%s\"\n\n", (
char *)pCommand );
 
   85     status = pthread_mutex_lock(&
mutex);   
assert(status == 0);
 
   87     status = pthread_mutex_unlock(&
mutex); 
assert(status == 0);
 
  107 void Cmd_RunStarter( 
char * pFileName, 
char * pBinary, 
char * pCommand, 
int nCores )
 
  109     FILE * pFile, * pFileTemp;
 
  110     pthread_t * pThreadIds;
 
  111     char * BufferCopy, * Buffer;
 
  112     int nLines, LineMax, Line, 
Len;
 
  119         fprintf( stdout, 
"The number of cores (%d) should be more than 1.\n", nCores ); 
 
  124     pFile = fopen( pFileName, 
"rb" );
 
  127         fprintf( stdout, 
"Input file \"%s\" cannot be opened.\n", pFileName ); 
 
  132     nLines = LineMax = Line = 0;
 
  133     while ( (c = fgetc(pFile)) != EOF )
 
  143     LineMax += LineMax + 100;
 
  144     LineMax += pBinary  ? 
strlen(pBinary) : 0;
 
  145     LineMax += pCommand ? 
strlen(pCommand) : 0;
 
  149     pThreadIds = 
ABC_ALLOC( pthread_t, nLines );
 
  152     if ( pCommand != NULL )
 
  156         for ( i = 0; fgets( Buffer, LineMax, pFile ) != NULL; i++ )
 
  159             for ( Len = 
strlen(Buffer) - 1; Len >= 0; Len-- )
 
  160                 if ( Buffer[Len] == 
'\n' || Buffer[Len] == 
'\r' || Buffer[Len] == 
'\t' || Buffer[Len] == 
' ' )
 
  166             if ( Buffer[0] == 0 || Buffer[0] == 
'\n' || Buffer[0] == 
'\r' || Buffer[0] == 
'\t' || Buffer[0] == 
' ' || Buffer[0] == 
'#' )
 
  170             pFileTemp = fopen( Buffer, 
"rb" );
 
  171             if ( pFileTemp == NULL )
 
  173                 fprintf( stdout, 
"Starter cannot open file \"%s\".\n", Buffer );
 
  185     for ( i = 0; fgets( Buffer, LineMax, pFile ) != NULL; i++ )
 
  188         for ( Len = 
strlen(Buffer) - 1; Len >= 0; Len-- )
 
  189             if ( Buffer[Len] == 
'\n' || Buffer[Len] == 
'\r' || Buffer[Len] == 
'\t' || Buffer[Len] == 
' ' )
 
  195         if ( Buffer[0] == 0 || Buffer[0] == 
'\n' || Buffer[0] == 
'\r' || Buffer[0] == 
'\t' || Buffer[0] == 
' ' || Buffer[0] == 
'#' )
 
  199         if ( pCommand != NULL )
 
  206         fprintf( stdout, 
"Calling:  %s\n", (
char *)BufferCopy );  
 
  212             status = pthread_mutex_lock(&
mutex);   
assert(status == 0);
 
  214             status = pthread_mutex_unlock(&
mutex); 
assert(status == 0);
 
  215             if ( Counter < nCores - 1 )
 
  221         status = pthread_mutex_lock(&
mutex);   
assert(status == 0);
 
  223         status = pthread_mutex_unlock(&
mutex); 
assert(status == 0);
 
  226         status = pthread_create( &pThreadIds[i], NULL, 
Abc_RunThread, (
void *)BufferCopy );  
assert(status == 0);
 
  236         status = pthread_mutex_lock(&
mutex);   
assert(status == 0);
 
  238         status = pthread_mutex_unlock(&
mutex); 
assert(status == 0);
 
  246     fprintf( stdout, 
"Finished processing commands in file \"%s\".  ", pFileName );
 
  251 #endif // pthreads are used 
static int nThreadsRunning
 
#define ABC_ALLOC(type, num)
 
static abctime Abc_Clock()
 
static int Abc_MaxInt(int a, int b)
 
ABC_NAMESPACE_IMPL_START void Cmd_RunStarter(char *pFileName, char *pBinary, char *pCommand, int nCores)
DECLARATIONS ///. 
 
static void Abc_PrintTime(int level, const char *pStr, abctime time)
 
void * Abc_RunThread(void *Command)
 
#define ABC_NAMESPACE_IMPL_END
 
#define ABC_NAMESPACE_IMPL_START
 
char * Abc_UtilStrsav(char *s)