1 /* Linuxthreads - a simple clone()-based implementation of Posix */
2 /* threads for Linux. */
3 /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
5 /* This program is free software; you can redistribute it and/or */
6 /* modify it under the terms of the GNU Library General Public License */
7 /* as published by the Free Software Foundation; either version 2 */
8 /* of the License, or (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU Library General Public License for more details. */
17 /* Waiting queues are represented by lists of thread descriptors
18 linked through their p_nextwaiting field. The lists are kept
19 sorted by decreasing priority, and then decreasing waiting time. */
21 static __inline__ void enqueue(pthread_descr * q, pthread_descr th)
23 int prio = th->p_priority;
24 ASSERT(th->p_nextwaiting == NULL);
25 for (; *q != NULL; q = &((*q)->p_nextwaiting)) {
26 if (prio > (*q)->p_priority) {
27 th->p_nextwaiting = *q;
35 static __inline__ pthread_descr dequeue(pthread_descr * q)
40 *q = th->p_nextwaiting;
41 th->p_nextwaiting = NULL;
46 static __inline__ int remove_from_queue(pthread_descr * q, pthread_descr th)
48 for (; *q != NULL; q = &((*q)->p_nextwaiting)) {
50 *q = th->p_nextwaiting;
51 th->p_nextwaiting = NULL;
58 static __inline__ int queue_is_empty(pthread_descr * q)