I wrote a program on redhat 9.0,  (kernel version: 2.4.20-9), but the apr_thread_cond_timedwait() caused deadlock, while apr_thread_cond_wait() worked. And when I compiled this program on Win32 platfrom, it worked properly. Then I rewrote all apr_thread_xxxs with native pthread_xxxs on Linux, the pthread_cond_timedwait worked, too.
Why? Can you tell me the reason?  The APR lib I used is the one shipped with Apache 2.0.45.
/*------------------------source begin ----------------------------------------*/
typedef struct cond_t cond_t;
struct cond_t {
 apr_thread_mutex_t *mutex;
 apr_thread_cond_t *cond;

static void * APR_THREAD_FUNC test_thread(apr_thread_t *thd,
                                          void *data)
 cond_t *tcond = data;
 printf("signal start...\n");
 printf("signal done!\n");
 return NULL;
static void test_cond(void)
 apr_thread_t *thd;
 apr_interval_time_t timeout = apr_time_from_sec(5);
 apr_status_t rv;
 cond_t *tcond = apr_pcalloc(p, sizeof(cond_t));
 apr_thread_mutex_create(&tcond->mutex, APR_THREAD_MUTEX_DEFAULT, p);
 apr_thread_cond_create(&tcond->cond, p);
 apr_thread_create(&thd, NULL, test_thread, tcond, p);
 printf("start waiting...\n");

 rv = apr_thread_cond_timedwait(tcond->cond, tcond->mutex, timeout);// this line causes deadlock
 //rv = pthread_cond_wait(tcond->cond, tcond->mutex);//this line works
 if (rv == APR_SUCCESS)
    printf("waiting ok\n");
    printf("waiting timeout/failure!\n");

/*------------------------source end ----------------------------------------*/

使用世界上最大的电子邮件系统— MSN Hotmail Get 2 months FREE*.