divert(-1) define(NEWPROC,) dnl define(BARRIER, `{ pthread_barrier_wait(&($1)); }') define(BARDEC, ` pthread_barrier_t ($1); ') define(BARINIT, `{ pthread_barrier_init(&($1), NULL, $2); }') define(BAREXCLUDE, `{;}') define(BARINCLUDE, `{;}') define(GSDEC, `long int ($1);') define(GSINIT, `{ ($1) = 0; }') define(GETSUB, `{ if (($1)<=($3)) ($2) = ($1)++; else { ($2) = -1; ($1) = 0; } }') define(NU_GSDEC, `long int ($1);') define(NU_GSINIT, `{ ($1) = 0; }') define(NU_GETSUB, `GETSUB($1,$2,$3,$4)') define(ADEC, `long int ($1);') define(AINIT, `{;}') define(PROBEND, `{;}') define(LOCKDEC, `pthread_mutex_t ($1);') define(LOCKINIT, `{pthread_mutex_init(&($1), NULL);}') define(LOCK, `{pthread_mutex_lock(&($1));}') define(UNLOCK, `{pthread_mutex_unlock(&($1));}') define(NLOCKDEC, `long int ($1);') define(NLOCKINIT, `{;}') define(NLOCK, `{;}') define(NUNLOCK, `{;}') define(ALOCKDEC, `pthread_mutex_t $1[$2];') define(ALOCKINIT, `{ unsigned long int i, error; for (i = 0; i < $2; i++) { error = pthread_mutex_init(&$1[i], NULL); if (error != 0) { printf("Error while initializing array of locks.\n"); exit(-1); } } }') define(ALOCK, `{pthread_mutex_lock(&$1[$2]);}') define(AULOCK, `{pthread_mutex_unlock(&$1[$2]);}') define(PAUSEDEC, ` struct { pthread_mutex_t mutex; pthread_cond_t cond_var; unsigned long int Flag; } $1; ') define(PAUSEINIT, `{ pthread_mutex_init(&$1.mutex, NULL); pthread_cond_init(&$1.cond_var, NULL); $1.Flag = 0; } ') define(CLEARPAUSE, `{ $1.Flag = 0; pthread_mutex_unlock(&$1.mutex);} ') define(SETPAUSE, `{ pthread_mutex_lock(&$1.mutex); $1.Flag = 1; pthread_cond_broadcast(&$1.cond_var); pthread_mutex_unlock(&$1.mutex);} ') define(EVENT, `{;}') define(WAITPAUSE, `{ pthread_mutex_lock(&$1.mutex); if ($1.Flag == 0) { pthread_cond_wait(&$1.cond_var, &$1.mutex); } }') define(PAUSE, `{;}') define(AUG_ON, ` ') define(AUG_OFF, ` ') define(TRACE_ON, ` ') define(TRACE_OFF, ` ') define(REF_TRACE_ON, ` ') define(REF_TRACE_OFF, ` ') define(DYN_TRACE_ON, `;') define(DYN_TRACE_OFF, `;') define(DYN_REF_TRACE_ON, `;') define(DYN_REF_TRACE_OFF, `;') define(DYN_SIM_ON, `;') define(DYN_SIM_OFF, `;') define(DYN_SCHED_ON, `;') define(DYN_SCHED_OFF, `;') define(AUG_SET_LOLIMIT, `;') define(AUG_SET_HILIMIT, `;') define(MENTER, `{;}') define(DELAY, `{;}') define(CONTINUE, `{;}') define(MEXIT, `{;}') define(MONINIT, `{;}') define(WAIT_FOR_END, `{ long int i, error; for (i = 1; i < ($1); i++) { error = pthread_join(PThreadTable[i], NULL); if (error != 0) { printf("Error in pthread_join().\n"); exit(-1); } } }') define(CREATE, `{ long int i, error; pthread_attr_t attr; error = pthread_attr_init(&attr); if (error != 0) { fprintf(stderr, "*** Error in pthread_attr_init\n"); exit(1); } // Hypothèse : le thread "main" s exécute sur le proc 0 ; pour almos utiliser l option -p x de exec dans le shrc for (i = 1; i < ($2); i++) { pthread_attr_setcpuid_np(&attr, i, NULL); error = pthread_create(&PThreadTable[i], &attr, (void * (*)(void *))($1), NULL); if (error != 0) { printf("Error in pthread_create().\n"); exit(-1); } } $1(); }') define(MAIN_INITENV, `{;}') define(MAIN_END, `{ *(unsigned int *) 0x0 = 0xDEADDEAD; return 0; }') define(MAIN_ENV,` #include //#include #include #include #define MAX_THREADS 512 pthread_t PThreadTable[MAX_THREADS]; ') define(ENV, ` ') define(EXTERN_ENV, ` #include //#include #include #include extern pthread_t PThreadTable[]; ') define(G_MALLOC, `malloc($1);') define(G_FREE, `free($1);') define(G_MALLOC_F, `malloc($1)') define(NU_MALLOC, `malloc($1);') define(NU_FREE, `free($1);') define(NU_MALLOC_F, `malloc($1)') define(GET_HOME, `{($1) = 0;}') define(GET_PID, `{($1) = 0;}') define(AUG_DELAY, `{sleep ($1);}') define(ST_LOG, `{;}') define(SET_HOME, `{;}') define(CLOCK, `{ struct timeval timer; gettimeofday(&timer, NULL); ($1) = (unsigned long long int) (timer.tv_sec); // Number of cycles of simulation }') divert(0)