From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075320706388.tru64-unix-managers.marc@archive.invalid> From: Lars Rossen Date: Fri, 02 Jun 1995 11:31:15 +0000 To: tru64-unix-managers Subject: Possible bug in pthreads library. X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075320706388 Dear all The program below shows what we belive is an error in the pthread_cond_timedwait() call. when called with days < 25 then all is ok. If called with 24 < days < 49 then the timer times out imediatly (not ok). If called with days > 50 the timer call fails when compiled and run on OSF/1 v3.2 and 3.2A but on v2.1 it seem ok (we have not waited 50 days to verify :-) Could someone please help. Cheers Lars +-----------------------------------------------------------------------------+ | Lars Rossen E-mail: Lars.Rossen@netman.dk | | NetMan A/S Phone : +45 3966 4020 | | Vandtaarnsvej 77 Fax : +45 3966 0675 | | 2860 Soeborg Home : Phone: +45 3670 3676 | | Denmark Knud Anchersvej 95, 2610 R{\o}dovre | +-----------------------------------------------------------------------------+ ******************************************************************************** #include #include #include #include #include #include #include pthread_mutex_t mutex; pthread_cond_t cond; TimerMain(int days) { struct timespec abstime; /* lock mutex before wait */ pthread_mutex_lock(&mutex); while(1) { struct timespec delta; delta.tv_sec = days*24*60*60; delta.tv_nsec = 0; pthread_get_expiration_np(&delta, &abstime); // Wait for timeout if ( pthread_cond_timedwait(&cond, &mutex, &abstime) == -1 ) { if ( errno != EAGAIN ) { printf("Bad timer call\n"); break; } // Timeout printf("Timeout\n"); } // Else signaled } pthread_mutex_unlock(&mutex); return 0; } int main(int argc, char *argv[]) { if ( argc !=2 ) { printf("Usage: %s \n", argv[0]); exit(1); } pthread_mutex_init(&mutex,pthread_mutexattr_default); pthread_cond_init(&cond,pthread_condattr_default); TimerMain(atoi(argv[1])); return 0; } ******************************************************************************** Compile it with: cc prog.c -lpthreads -lm -lmach -lc_r -o prog