12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- static __inline__ void enqueue(pthread_descr * q, pthread_descr th)
- {
- int prio = th->p_priority;
- ASSERT(th->p_nextwaiting == NULL);
- 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;
- }
|