Re: [Ecls-list] Mutex & fairness

2012-03-28 Thread Juan Jose Garcia-Ripoll
On Wed, Mar 28, 2012 at 3:25 AM, Daniel Herring wrote: > The exact same issue occurs with condition variables. As a result, the > caller of pthread_cond_signal frequently needs to use the same mutex as the > caller of pthread_cond_wait. > Yes, I know, but condition variables are really not a goo

Re: [Ecls-list] Mutex & fairness

2012-03-27 Thread Matthew Mondor
On Tue, 27 Mar 2012 21:25:38 -0400 (EDT) Daniel Herring wrote: Hopefully Juan Jose can clarify if I'm wrong in the following answers, as I'm not aware of all issues involved with locking and interrupts in ECL. > Can't you use pthread_mutex_trylock to query whether a thread is locked? > Not supe

Re: [Ecls-list] Mutex & fairness

2012-03-27 Thread Daniel Herring
On Tue, 27 Mar 2012, Juan Jose Garcia-Ripoll wrote: > This is tricky. Ideally we should not need any polling at all. The only > reason for polling to exist is because we do not have a portable > implementation of a wait queue, such as C++'s new eventcount. In other words, > we the slow path > l

Re: [Ecls-list] Mutex & fairness

2012-03-27 Thread Juan Jose Garcia-Ripoll
On Tue, Mar 27, 2012 at 2:41 PM, Daniel Herring wrote: > Here are some thoughts to make a fair lock fast: Quickly detect and take > the fast path (atomics to bypass all locking). > This is already throughout ECL's code. Atomics have been incorporated via libatomics and their intelligent headers

Re: [Ecls-list] Mutex & fairness

2012-03-27 Thread Daniel Herring
On Sun, 25 Mar 2012, Juan Jose Garcia-Ripoll wrote: > Working further on the userspace implementation locks, I realized that it is > hard to come up with an implementation that is both fast and fair, > understanding by the last concept the fact that all threads have more or less > the same > ch

[Ecls-list] Mutex & fairness

2012-03-25 Thread Juan Jose Garcia-Ripoll
Working further on the userspace implementation locks, I realized that it is hard to come up with an implementation that is both fast and fair, understanding by the last concept the fact that all threads have more or less the same chances to acquire a lock. POSIX threads seem to acomplish this nice