This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: condition variables and mutexes



> > Is it useful to be able to wait on a condition variable without
> > atomically releasing a mutex when you stop and reacquiring the mutex
> > when you're done?  In other words, should Guile provide a
> > (condition-variable-wait CONDVAR) operation, in addition to the normal
> > (condition-variable-wait CONDVAR MUTEX) operation?
> 
> No. A condition variable is always used in association with a mutex,
> and it is critical for the proper use of the condition variable that
> the mutex be unlocked atomically as part of the wait, and re-locked
> when the thread is returned to.

Okay,  I'll un-export that function again...

> However, a condition variable is usually associated with exactly one
> mutex. Maybe it would be more useful to pass the mutex as part of the
> condition variable constructor.
> 
> References say that using the same condition variable with more than
> one mutex is highly likely to screw you over.

Hmm.  Something to think about when we're ready to think about
threading seriously...