[omniORB] Lockup on Solaris 2.5.1 with Y2K patch
David Riddoch
djr@uk.research.att.com
Wed, 23 Jun 1999 17:30:47 +0100 (GMT)
Hi,
Lots of valid points have been made, but the following (which addresses
all of them I think) also locks up ...
#include <pthread.h>
#include <iostream.h>
#include <time.h>
pthread_cond_t cond;
pthread_mutex_t mutex;
pthread_t thr;
int died = 0;
extern "C"
void*
worker(void* ptr)
{
while (1) {
pthread_mutex_lock(&mutex);
if( died ) break;
pthread_mutex_unlock(&mutex);
struct timespec abs;
clock_gettime(CLOCK_REALTIME,&abs);
abs.tv_sec += 1;
pthread_mutex_lock(&mutex);
pthread_cond_timedwait(&cond,&mutex,&abs);
pthread_mutex_unlock(&mutex);
}
cerr << "worker exit" << endl;
pthread_exit(0);
return 0;
}
int
main(int,char**)
{
pthread_cond_init(&cond,0);
pthread_mutex_init(&mutex,0);
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&thr,&attr,worker,0);
{
void** status = 0;
pthread_mutex_lock(&mutex);
died = 1;
pthread_mutex_unlock(&mutex);
pthread_join(thr,status);
cerr << "killer done." << endl;
}
return 0;
}