mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-04 22:40:25 +02:00
* coop.c (coop_condition_variable_wait): Removed
(coop_condition_variable_wait_mutex): Folded logic of coop_mutex_unlock into coop_condition_variable_wait_mutex to prevent condvar signal lossage. Previously, another thread could start to run after unlocking the mutex but before putting the current thread on the wait queue. If that thread then would signal the first, the signal would be lost. (Thanks to Christian Lynbech.)
This commit is contained in:
parent
3b2ee8bcdf
commit
b322f09ab8
3 changed files with 42 additions and 28 deletions
|
@ -1,3 +1,17 @@
|
|||
1998-11-19 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
|
||||
|
||||
* readline.c (scm_init_readline): Set
|
||||
rl_basic_word_break_characters. (Thanks to Ian Grant.)
|
||||
|
||||
* coop.c (coop_condition_variable_wait): Removed
|
||||
(coop_condition_variable_wait_mutex): Folded logic of
|
||||
coop_mutex_unlock into coop_condition_variable_wait_mutex to
|
||||
prevent condvar signal lossage. Previously, another thread could
|
||||
start to run after unlocking the mutex but before putting the
|
||||
current thread on the wait queue. If that thread then would
|
||||
signal the first, the signal would be lost. (Thanks to Christian
|
||||
Lynbech.)
|
||||
|
||||
1998-11-17 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
|
||||
|
||||
* eval.c (SCM_CEVAL): Added missing case for cclo. (Thanks to
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* If you do not wish that, delete this exception notice. */
|
||||
|
||||
|
||||
/* $Id: coop.c,v 1.14 1998-10-13 23:17:09 jimb Exp $ */
|
||||
/* $Id: coop.c,v 1.15 1998-11-19 08:15:22 mdj Exp $ */
|
||||
|
||||
/* Cooperative thread library, based on QuickThreads */
|
||||
|
||||
|
@ -333,6 +333,8 @@ coop_mutex_unlock (m)
|
|||
|
||||
old = coop_global_curr;
|
||||
coop_global_curr = newthread;
|
||||
/* The new thread came into m->waiting through a lock operation.
|
||||
It now owns this mutex. */
|
||||
m->owner = coop_global_curr;
|
||||
QT_BLOCK (coop_yieldhelp, old, &coop_global_runq, newthread->sp);
|
||||
}
|
||||
|
@ -370,31 +372,6 @@ coop_condition_variable_init (c)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
static int
|
||||
coop_condition_variable_wait (coop_c *c)
|
||||
#else
|
||||
static int
|
||||
coop_condition_variable_wait (c)
|
||||
coop_c *c;
|
||||
#endif
|
||||
{
|
||||
coop_t *old, *newthread;
|
||||
|
||||
#ifdef GUILE_ISELECT
|
||||
newthread = coop_wait_for_runnable_thread();
|
||||
if (newthread == coop_global_curr)
|
||||
coop_abort ();
|
||||
#else
|
||||
newthread = coop_next_runnable_thread();
|
||||
#endif
|
||||
old = coop_global_curr;
|
||||
coop_global_curr = newthread;
|
||||
QT_BLOCK (coop_yieldhelp, old, &(c->waiting), newthread->sp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
int
|
||||
coop_condition_variable_wait_mutex (coop_c *c, coop_m *m)
|
||||
|
@ -405,8 +382,30 @@ coop_condition_variable_wait_mutex (c, m)
|
|||
coop_m *m;
|
||||
#endif
|
||||
{
|
||||
coop_mutex_unlock (m);
|
||||
coop_condition_variable_wait (c);
|
||||
coop_t *old, *newthread;
|
||||
|
||||
/* coop_mutex_unlock (m); */
|
||||
newthread = coop_qget (&(m->waiting));
|
||||
if (newthread != NULL)
|
||||
{
|
||||
m->owner = newthread;
|
||||
}
|
||||
else
|
||||
{
|
||||
m->owner = NULL;
|
||||
#ifdef GUILE_ISELECT
|
||||
newthread = coop_wait_for_runnable_thread();
|
||||
if (newthread == coop_global_curr)
|
||||
coop_abort ();
|
||||
#else
|
||||
newthread = coop_next_runnable_thread();
|
||||
#endif
|
||||
}
|
||||
coop_global_curr->top = &old;
|
||||
old = coop_global_curr;
|
||||
coop_global_curr = newthread;
|
||||
QT_BLOCK (coop_yieldhelp, old, &(c->waiting), newthread->sp);
|
||||
|
||||
coop_mutex_lock (m);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue