13 for(i=0;(i<MAXTHREAD)&&(
thread_table[i].thread_key != tid.thread_key);i++);
22 *prio = prio_vec.stat_prio;
31 int thr_create(
void *base,
size_t size,
void (*func)(),
void *args,
long flags,
int *tid)
33 for(i=0;(i<MAXTHREAD)&&(
thread_table[i].thread_key >=0 );i++);
35 stat = lwp_create( &
thread_table[i], func, MINPRIO, flags, lwp_newstk(), 1, args);
62 mutex_init(&(rw->
lock), 0, 0);
70 mutex_destroy(&(rw->
lock));
71 cond_destroy(&(rw->
r_cond));
72 cond_destroy(&(rw->
w_cond));
77 mutex_lock(&(rw->
lock));
79 cond_wait(&(rw->
r_cond), 0);
81 mutex_unlock(&(rw->
lock));
86 mutex_lock(&(rw->
lock));
88 cond_wait(&(rw->
w_cond), 0);
90 mutex_unlock(&(rw->
lock));
95 mutex_lock(&(rw->
lock));
100 cond_broadcast(&(rw->
w_cond));
101 cond_broadcast(&(rw->
r_cond));
102 mutex_unlock(&(rw->
lock));
108 mutex_init(&(sem->
lock), 0, 0 );
109 cond_init(&(sem->
cond), &(sem->
lock));
115 mutex_destroy(&(sem->
lock));
116 cond_destroy(&(sem->
cond));
121 mutex_lock(&(sem->
lock));
122 while (sem->
count == 0){
123 cond_wait(&(sem->
cond), &(sem->
lock));}
125 mutex_unlock(&(sem->
lock));
131 mutex_lock(&(sem->
lock));
138 mutex_unlock(&(sem->
lock));
144 mutex_lock(&(sem->
lock));
146 cond_broadcast(&(sem->
cond));
147 mutex_unlock(&(sem->
lock));
153 struct timeval quantum;
155 quantum.tv_usec = 10000;
158 lwp_resched(MINPRIO);
166 for(i=0;i<MAXTHREAD;i++)
178 lwp_setstkcache(32*1024*4, MAXTHREAD);
179 lwp_create((thread_t *)0, scheduler, 2, 0, lwp_newstk(), 0);
180 lwp_setpri(
SELF,MINPRIO);
int rwlock_destroy(rwlock_t *)
int thr_setprio(int, int)
int sema_init(sema_t *, unsigned int, int, void *)
int rwlock_init(rwlock_t *, int, void *)
int rw_wrlock(rwlock_t *)
struct @10 thread_table[]
int sema_destroy(sema_t *)
int thr_create(void *, size_t, void(*)(), void *, long, int *)
int rw_rdlock(rwlock_t *)
int sema_trywait(sema_t *)
int rw_unlock(rwlock_t *)
int thr_getprio(int tid, int *prio)
int sema_post(sema_t *sem)