#ifdef __STDC__
void
coop_yield()
#else
void
coop_yield()
#endif
{
coop_t *old = NULL;
coop_t *newthread;
newthread = coop_next_runnable_thread();
/* There may be no other runnable threads. Return if this is the
case. */
if (newthread == NULL)
return;
old = coop_global_curr;
coop_global_curr = newthread;
QT_BLOCK (coop_yieldhelp, old, &coop_global_runq, newthread->sp);
}
Here is a possible scenario: a Guile thread calls a C/C++ function
that, in turn calls (as a callback, through some C/C++ code) a Scheme
procedure. During its evaluation (using scm_apply), a context switch
occurs. What is the contents of `coop_global_curr'? Is it possible
that `newthread' replaces the thread that called the C/C++ function
but some non-existing thread (kept in `coop_global_curr') is
``blocked'' instead (so that the thread that called the C/C++ function
is lost)?
In my C/C++ there should be no code that can block infinitely, but I
can see that either a thread not running or a thread is blocked when
it is not supposed to be blocked, by looking at CPU usage.
Aleksandar