16 thr_t = pthread_self();
17 for(i=0;(i<MAXTHREAD)&&(
thread_table[i][0] != thr_t);i++);
36 if ((piro >= PTHREAD_MIN_PRIORITY) &&
37 (piro =< PTHREAD_MAX_PRIORITY))
40 else return(EINVAL); }
44 void *args,
long flags,
int *
tid)
46 pthread_attrt th_attr;
49 pthread_attr_init(&th_attr);
51 fprintf(stderr,
"Warning in thr_create(): flags doesn't support!\n");
52 if (size >= PTHREAD_STACK_MIN) pthread_attr_setstacksize(&th_attr, size);
53 stat = pthread_create( &
thread_table[i], th_attr, func, args);
60 fprintf(stderr,
"Error in thr_continue: POSIX thread doesn't supported.\n");
66 fprintf(stderr,
"Error in thr_suspend: POSIX thread doesn't supported.\n");
77 if ( *depature !=
NULL){
78 fprintf(stderr,
"Warrning in thr_join: argument 'depature' must be NULL.\n");
113 pthread_mutex_init(&(sem->
lock),
NULL);
114 pthread_cond_init(&(sem->
cond),
NULL);
120 pthread_mutex_destroy(&(sem->
lock));
121 pthread_cond_destroy(&(sem->
cond));
126 pthread_mutex_lock(&(sem->
lock));
127 while (sem->
count == 0){
128 pthread_cond_wait(&(sem->
cond), &(sem->
lock));}
130 pthread_mutex_unlock(&(sem->
lock));
136 stat = pthread_mutex_trylock(&(sem->
lock));
137 if (stat != 0)
return (stat);
144 pthread_mutex_unlock(&(sem->
lock));
150 pthread_mutex_lock(&(sem->
lock));
152 pthread_cond_signal(&(sem->
cond));
153 pthread_mutex_unlock(&(sem->
lock));
166 mutex_init(&(rw->
lock), 0, 0);
174 mutex_destroy(&(rw->
lock));
175 cond_destroy(&(rw->
r_cond));
176 cond_destroy(&(rw->
w_cond));
181 mutex_lock(&(rw->
lock));
183 cond_wait(&(rw->
r_cond), 0);
185 mutex_unlock(&(rw->
lock));
190 mutex_lock(&(rw->
lock));
192 cond_wait(&(rw->
w_cond), 0);
194 mutex_unlock(&(rw->
lock));
199 mutex_lock(&(rw->
lock));
204 cond_broadcast(&(rw->
w_cond));
205 cond_broadcast(&(rw->
r_cond));
206 mutex_unlock(&(rw->
lock));
int thr_setprio(int tid, int prio)
int thr_join(int tid, int *depature, void **status)
pthread_t thread_table[MAXTHREAD][2]
int sema_init(sema_t *sem, unsigned int c, int d, void *e)
int thr_continue(int tid)
int thr_getprio(int tid, int *prio)
int sema_destroy(sema_t *sem)
int thr_create(void *base, size_t size, void(*func)(), void *args, long flags, int *tid)
int rw_rdlock(rwlock_t *rw)
int thr_kill(int tid, int sig)
int rw_unlock(rwlock_t *rw)
int rwlock_destroy(rwlock_t *rw)
int sema_trywait(sema_t *sem)
int sema_post(sema_t *sem)
int rw_wrlock(rwlock_t *rw)
int sema_wait(sema_t *sem)
int rwlock_init(rwlock_t *rw, int c, void *d)