/* * mthr.h - Cabecalho das funcoes para threads pseudo-paralelas * Autores: Henrique Przibisczki de Oliveira * Tiago Barabasz * IC-UNICAMP */ #include #include #include #include #include #include #define HABILITAR 1 #define DESABILITAR 0 #define NUM_MAX_THR 1024 #define sched sched_yield() static int MODO_RANDOM=1; /* 1:Sim,0:nao */ static int DEBUG=0; static inline void step() { if ((((rand()+pthread_self())%10)>=5)&& MODO_RANDOM){ sched; if (DEBUG) printf("Sched\n"); } else {if (DEBUG) printf("NonSched\n");} } struct th{ pthread_t a; const pthread_attr_t *b; void *c; void *d; } pthr[NUM_MAX_THR]; void addPthread(const pthread_attr_t *b,void *(*c)(void *), void *d); void Pthread_create(); void Pthread_join();