*maxptr = thr->p_nextwaiting;
*maxptr = thr->p_nextlock;
void internal_function __pthread_unlock(struct _pthread_fastlock * lock){  long oldstatus;  pthread_descr thr, * ptr, * maxptr;  int maxprio;again:  oldstatus = lock->__status;  if (oldstatus == 0 || oldstatus == 1) {    /* No threads are waiting for this lock.  Please note that we also       enter this case if the lock is not taken at all.  If this wouldn't       be done here we would crash further down.  */    if (! compare_and_swap(&lock->__status, oldstatus, 0, &lock->__spinlock))      goto again;    return;  }  /* Find thread in waiting queue with maximal priority */  ptr = (pthread_descr *) &lock->__status;  thr = (pthread_descr) oldstatus;  maxprio = 0;  maxptr = ptr;  while (thr != (pthread_descr) 1) {    if (thr->p_priority >= maxprio) {      maxptr = ptr;      maxprio = thr->p_priority;    }    ptr = &(thr->p_nextwaiting);    thr = *ptr;  }  /* Remove max prio thread from waiting list. */  if (maxptr == (pthread_descr *) &lock->__status) {    /* If max prio thread is at head, remove it with compare-and-swap       to guard against concurrent lock operation */    thr = (pthread_descr) oldstatus;    if (! compare_and_swap(&lock->__status,                           oldstatus, (long)(thr->p_nextwaiting),                           &lock->__spinlock))      goto again;  } else {    /* No risk of concurrent access, remove max prio thread normally */    thr = *maxptr;    *maxptr = thr->p_nextwaiting;  }  /* Wake up the selected waiting thread */  thr->p_nextwaiting = NULL;  restart(thr);}