summaryrefslogtreecommitdiff
path: root/libguile/coop.c
diff options
context:
space:
mode:
authorMikael Djurfeldt <djurfeldt@nada.kth.se>2001-10-06 16:30:20 +0000
committerMikael Djurfeldt <djurfeldt@nada.kth.se>2001-10-06 16:30:20 +0000
commit152812c0575076645a6f41940cac1133ce24ffa9 (patch)
tree6f0666d889aab35af46b5a44deea3f0f36ca1c47 /libguile/coop.c
parent2d7cbf9e0baba2586239f55c29fdd6ba7db20055 (diff)
downloadguile-152812c0575076645a6f41940cac1133ce24ffa9.tar.gz
* coop.c (mother_awake_p): New variable.
(coop_create): Set mother_awake_p before creating or signalling mother; wait until mother is going to sleep before returning. (mother): Reset mother_awake_p before going to sleep.
Diffstat (limited to 'libguile/coop.c')
-rw-r--r--libguile/coop.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libguile/coop.c b/libguile/coop.c
index a6ef33ed2..987a71f9a 100644
--- a/libguile/coop.c
+++ b/libguile/coop.c
@@ -40,7 +40,7 @@
* If you do not wish that, delete this exception notice. */
-/* $Id: coop.c,v 1.27 2001-03-10 03:09:07 mdj Exp $ */
+/* $Id: coop.c,v 1.28 2001-10-06 16:30:20 mdj Exp $ */
/* Cooperative thread library, based on QuickThreads */
@@ -171,6 +171,7 @@ static pthread_cond_t coop_cond_quit;
static pthread_cond_t coop_cond_create;
static pthread_mutex_t coop_mutex_create;
static pthread_t coop_mother;
+static int mother_awake_p = 0;
static coop_t *coop_child;
#endif
@@ -584,6 +585,7 @@ mother (void *dummy)
NULL,
dummy_start,
coop_child);
+ mother_awake_p = 0;
do
res = pthread_cond_wait (&coop_cond_create, &coop_mutex_create);
while (res == EINTR);
@@ -618,6 +620,7 @@ coop_create (coop_userf_t *f, void *pu)
t->n_keys = 0;
#ifdef GUILE_PTHREAD_COMPAT
coop_child = t;
+ mother_awake_p = 1;
if (coop_quitting_p < 0)
{
coop_quitting_p = 0;
@@ -635,7 +638,7 @@ coop_create (coop_userf_t *f, void *pu)
* condition variable because they are not safe against
* pre-emptive switching.
*/
- while (coop_child)
+ while (coop_child || mother_awake_p)
usleep (0);
#else
t->sto = malloc (COOP_STKSIZE);