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));