site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com Hello, struct timeval tv; gettimeofday(&tv, NULL); struct timespec abstime; abstime.tv_sec = tv.tv_sec + milliseconds / 1000; abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000; if (abstime.tv_nsec >= 1000000000) { abstime.tv_nsec -= 1000000000; abstime.tv_sec++; } pthread_mutex_lock(&_mutex); // error handling omitted while (...) { int rc = pthread_cond_timedwait(&_cond, &_mutex, &abstime))) if (rc == ETIMEDOUT) // we never get here if milliseconds == 0 ... } Any ideas? Thanks and best regards, Günter Obiltschnig http://www.obiltschnig.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I have a strange problem with pthread_cond_timedwait() on 10.4. The following code snipped works fine on 10.3 (and a bunch of other POSIX platforms). On 10.4 however, if milliseconds == 0, the program hangs forever in pthread_cond_timedwait() instead of returning ETIMEDOUT. milliseconds == 0 basically means that the absolute time value passed to pthread_cond_timedwait() is the result of gettimeofday(). If milliseconds has a value of 10, which means that the absolute time passed to pthread_cond_timedwait() is about 10ms into the future, pthread_cond_timedwait() returns ETIMEDOUT as expected. Could it be that there is a bug in pthread_cond_timedwait() that causes it to block forever if the absolute time value passed to it lies in the past? This email sent to site_archiver@lists.apple.com