123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- static __inline__ void enqueue(pthread_descr * q, pthread_descr th)
- {
- int prio = th->p_priority;
- for (; *q != NULL; q = &((*q)->p_nextwaiting)) {
- if (prio > (*q)->p_priority) {
- th->p_nextwaiting = *q;
- *q = th;
- return;
- }
- }
- *q = th;
- }
- static __inline__ pthread_descr dequeue(pthread_descr * q)
- {
- pthread_descr th;
- th = *q;
- if (th != NULL) {
- *q = th->p_nextwaiting;
- th->p_nextwaiting = NULL;
- }
- return th;
- }
- static __inline__ int remove_from_queue(pthread_descr * q, pthread_descr th)
- {
- for (; *q != NULL; q = &((*q)->p_nextwaiting)) {
- if (*q == th) {
- *q = th->p_nextwaiting;
- th->p_nextwaiting = NULL;
- return 1;
- }
- }
- return 0;
- }
- static __inline__ int queue_is_empty(pthread_descr * q)
- {
- return *q == NULL;
- }
|