From 2acf5526612dd7bd01b646c0941031437fb97d92 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Thu, 20 Aug 1998 22:21:35 +0000 Subject: [PATCH] update --- lib/isc/pthreads/condition.c | 20 ++++++++++++++++++++ lib/isc/pthreads/include/isc/condition.h | 11 ++++++----- lib/isc/task.c | 6 ++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 lib/isc/pthreads/condition.c diff --git a/lib/isc/pthreads/condition.c b/lib/isc/pthreads/condition.c new file mode 100644 index 0000000000..afbfa7b022 --- /dev/null +++ b/lib/isc/pthreads/condition.c @@ -0,0 +1,20 @@ + +#include +#include + +boolean_t +os_condition_waituntil(os_condition_t *c, os_mutex_t *m, struct timespec *ts, + boolean_t *timeout) +{ + int result; + + result = pthread_cond_timedwait(c, m, ts); + if (result == 0) { + *timeout = FALSE; + return (TRUE); + } else if (result == ETIMEDOUT) { + *timeout = TRUE; + return (TRUE); + } + return (FALSE); +} diff --git a/lib/isc/pthreads/include/isc/condition.h b/lib/isc/pthreads/include/isc/condition.h index 33a0cb872c..4d39d595d6 100644 --- a/lib/isc/pthreads/include/isc/condition.h +++ b/lib/isc/pthreads/include/isc/condition.h @@ -3,9 +3,9 @@ #define CONDITION_H 1 #include -#include #include +#include #include typedef pthread_cond_t os_condition_t; @@ -13,12 +13,13 @@ typedef pthread_cond_t os_condition_t; #define os_condition_init(cp) (pthread_cond_init((cp), NULL) == 0) #define os_condition_wait(cp, mp) (pthread_cond_wait((cp), (mp)) == 0) -#define os_condition_waituntil(cp, mp, tsp, top) \ - (pthread_cond_timedwait((cp), (mp), (tsp)) == 0 \ - ? TRUE \ - : ((*(top) = (errno == ETIMEDOUT)), FALSE)) #define os_condition_signal(cp) (pthread_cond_signal((cp)) == 0) #define os_condition_broadcast(cp) (pthread_cond_broadcast((cp)) == 0) #define os_condition_destroy(cp) (pthread_cond_destroy((cp)) == 0) +boolean_t os_condition_waituntil(os_condition_t *, + os_mutex_t *, + struct timespec *, + boolean_t *); + #endif /* CONDITION_H */ diff --git a/lib/isc/task.c b/lib/isc/task.c index 4022db0acf..15b21d8b59 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -766,6 +766,12 @@ task_manager_destroy(task_manager_t *managerp) { /* * Wait for all the worker threads to exit. + * + * XXX This will become a timed wait. If all the workers haven't + * died after we've waited the specified interval, we will + * kill the worker threads. Should we join with the worker + * threads after killing them or just leave them detached and + * hope they go away? */ while (manager->workers > 0) WAIT(&manager->no_workers, &manager->lock);