On 3/18/11 4:41 PM, Ville Voutilainen wrote:
On 18 March 2011 17:37, Mark Evensonevenson@panix.com wrote:
This was the previous implementation, which was the subject of the criticism:
(defun condition-wait (condition lock) (check-type condition condition-variable) (release-lock lock) (do () ((acquire-lock lock nil)) (threads:synchronized-on condition (threads:object-wait condition))))
If this is directly mapped to a pthread implementation, the loop must be there.
I think it is slightly different, as the semantics of BT:CONDITION-WAIT are merely that the lock is always reacquired before returning. The caller of BT:CONDITION-WAIT is required to check for spurious wakeups.
I believe the race condition is on the the synchronization on the condition variable, not on the mutex lock.
The condition variable needs to use the mutex lock given, not a separate lock.
The condition variable interface is using the mutex lock specified in BT:CONDITION-WAIT. For the ABCL implementation, I'm using the Java monitor associated with the condition variable for the additional synchronization needed to implement BT:CONDITION-NOTIFY which couldn't use the mutex lock without contention problems. But definitely check my logic here, as it has been faulty before.
On 18 March 2011 17:54, Mark Evenson evenson@panix.com wrote:
The condition variable interface is using the mutex lock specified in BT:CONDITION-WAIT. For the ABCL implementation, I'm using the Java monitor associated with the condition variable for the additional synchronization needed to implement BT:CONDITION-NOTIFY which couldn't use the mutex lock without contention problems. But definitely check my logic here, as it has been faulty before.
If we are implementing posix-style-semantics, we could avoid reinventing that wheel on java, and use http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/... which has the posix semantics.
On 3/18/11 5:01 PM, Ville Voutilainen wrote: […]
If we are implementing posix-style-semantics, we could avoid reinventing that wheel on java, and use http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/... which has the posix semantics.
My implementation of BORDEAUX-THREADS *is* using this package for the base mutex lock. The problem for the condition variables is that the java.util.concurrent implementation requires that a condition variable be [created from the lock it is to be used with][1] which is not a requirement for pthreads, so BT:MAKE-CONDITION-VARIABLE doesn't contain a reference to the lock that will be used. I tried one implementation strategy that had BT:CONDITION-WAIT call this method the first time it is invoked, but that didn't seem to work very well. If there is something clever that I have missed, please help me find it.
[1]: http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/...
On 18 March 2011 18:09, Mark Evenson evenson@panix.com wrote:
mutex lock. The problem for the condition variables is that the java.util.concurrent implementation requires that a condition variable be [created from the lock it is to be used with][1] which is not a requirement
Ouch. I had forgotten about that, sorry.
didn't seem to work very well. If there is something clever that I have missed, please help me find it.
The condvar creation problem seems hard. I don't currently have an idea how to solve it.
I have a plane to catch tomorrow, so I probably won't have time to look at the current problems in any detail for a week or so. :(
armedbear-devel@common-lisp.net