=================================================================== RCS file: /afs/sipb/project/pthreads/src/CVS/pthreads/pthreads/cond.c,v retrieving revision 1.50.2.1 diff -c -r1.50.2.1 cond.c *** 1.50.2.1 1994/08/20 03:32:30 --- cond.c 1994/10/20 04:22:31 *************** *** 181,189 **** pthread_yield(); } /* Set pthread wakeup time*/ /* Install us on the sleep queue */ ! sleep_schedule (current_time, &(pthread_run->wakeup_time)); pthread_queue_enq(&cond->c_queue, pthread_run); pthread_mutex_unlock(mutex); --- 181,191 ---- pthread_yield(); } /* Set pthread wakeup time*/ + pthread_run->wakeup_time.ts_sec = abstime->ts_sec; + pthread_run->wakeup_time.ts_nsec = abstime->ts_nsec; /* Install us on the sleep queue */ ! sleep_schedule (& current_time, &(pthread_run->wakeup_time)); pthread_queue_enq(&cond->c_queue, pthread_run); pthread_mutex_unlock(mutex); *************** *** 196,208 **** * First remove ourselves from the sleep queue * then remove ourselves from the cond queue */ ! if (sleep_cancel(pthread_run)) { /* Remove ourselves from the condition variable queue */ while (SEMAPHORE_TEST_AND_SET(lock)) { pthread_yield(); } /* Need to lock ourself here ????? */ ! if (pthread_queue_remove(&cond->c_queue, pthread_run)) { SET_ERRNO(ETIMEDOUT); rval = ETIMEDOUT; } else { --- 198,210 ---- * First remove ourselves from the sleep queue * then remove ourselves from the cond queue */ ! if (sleep_cancel(pthread_run) == NOTOK) { /* Remove ourselves from the condition variable queue */ while (SEMAPHORE_TEST_AND_SET(lock)) { pthread_yield(); } /* Need to lock ourself here ????? */ ! if (pthread_queue_remove(&cond->c_queue, pthread_run) == OK) { SET_ERRNO(ETIMEDOUT); rval = ETIMEDOUT; } else { =================================================================== RCS file: /afs/sipb/project/pthreads/src/CVS/pthreads/pthreads/sleep.c,v retrieving revision 1.50.2.3 diff -c -r1.50.2.3 sleep.c *** 1.50.2.3 1994/10/19 03:58:02 --- sleep.c 1994/10/20 04:04:26 *************** *** 374,417 **** pthread_yield(); } ! if (pthread == pthread_sleep) { ! rval = OK; ! machdep_stop_timer(&delta_time); ! pthread_sleep = pthread_sleep->sll; ! current_time.ts_sec = delta_time.ts_sec; ! current_time.ts_nsec = delta_time.ts_nsec; ! current_time.ts_sec += pthread_sleep->wakeup_time.ts_sec; ! current_time.ts_nsec += pthread_sleep->wakeup_time.ts_nsec; ! if (current_time.ts_nsec > 1000000000) { ! current_time.ts_nsec -= 1000000000; ! current_time.ts_sec++; ! } ! machdep_start_timer(&(current_time), &(pthread_sleep->wakeup_time)); ! } else { ! /* ! * Locking is necessary to ensure that no other thread is modifing ! * the threads internal structures. It is unnecessary to maintain ! * a lock while we get another because the queue cannot be modified ! * without the lock on sleep_semaphore. ! */ ! pthread_last = pthread_sleep; ! qlock = &(pthread_last->lock); ! while (SEMAPHORE_TEST_AND_SET(qlock)) { ! pthread_yield(); ! } ! while (pthread_last = pthread_last->sll) { ! SEMAPHORE_RESET(qlock); qlock = &(pthread_last->lock); while (SEMAPHORE_TEST_AND_SET(qlock)) { pthread_yield(); } ! if (pthread_last->sll == pthread) { ! pthread_last->sll = pthread->sll; ! rval = OK; ! break; } } - SEMAPHORE_RESET(qlock); } pthread->state = PS_RUNNING; pthread->sll = NULL; --- 374,419 ---- pthread_yield(); } ! if (pthread_sleep) { ! if (pthread == pthread_sleep) { ! rval = OK; ! machdep_stop_timer(&delta_time); ! pthread_sleep = pthread_sleep->sll; ! current_time.ts_sec = delta_time.ts_sec; ! current_time.ts_nsec = delta_time.ts_nsec; ! current_time.ts_sec += pthread_sleep->wakeup_time.ts_sec; ! current_time.ts_nsec += pthread_sleep->wakeup_time.ts_nsec; ! if (current_time.ts_nsec > 1000000000) { ! current_time.ts_nsec -= 1000000000; ! current_time.ts_sec++; ! } ! machdep_start_timer(&(current_time), &(pthread_sleep->wakeup_time)); ! } else { ! /* ! * Locking is necessary to ensure that no other thread is modifing ! * the threads internal structures. It is unnecessary to maintain ! * a lock while we get another because the queue cannot be modified ! * without the lock on sleep_semaphore. ! */ ! pthread_last = pthread_sleep; qlock = &(pthread_last->lock); while (SEMAPHORE_TEST_AND_SET(qlock)) { pthread_yield(); } ! while (pthread_last = pthread_last->sll) { ! SEMAPHORE_RESET(qlock); ! qlock = &(pthread_last->lock); ! while (SEMAPHORE_TEST_AND_SET(qlock)) { ! pthread_yield(); ! } ! if (pthread_last->sll == pthread) { ! pthread_last->sll = pthread->sll; ! rval = OK; ! break; ! } } + SEMAPHORE_RESET(qlock); } } pthread->state = PS_RUNNING; pthread->sll = NULL;