Should nested mutexes work in Pharo 3.0?
Hi! :) I am playing around with Animations [1] in the Moose 5.0/Pharo 3.0 image [2]. Nested use of the same mutex seems to freeze the image. Should that work? Best, Marcel [1] https://github.com/marceltaeumel/animations [2] https://ci.inria.fr/moose/job/moose-5.0/lastSuccessfulBuild/artifact/moose-5... -- View this message in context: http://forum.world.st/Should-nested-mutexes-work-in-Pharo-3-0-tp4771110.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On 31/07/14 10:45, Marcel Taeumel wrote:
Hi! :)
I am playing around with Animations [1] in the Moose 5.0/Pharo 3.0 image [2]. Nested use of the same mutex seems to freeze the image. Should that work?
No, it should not :-) Use Monitor instead. Jan
Best, Marcel
[1] https://github.com/marceltaeumel/animations [2] https://ci.inria.fr/moose/job/moose-5.0/lastSuccessfulBuild/artifact/moose-5...
-- View this message in context: http://forum.world.st/Should-nested-mutexes-work-in-Pharo-3-0-tp4771110.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On Thu, 31 Jul 2014, Jan Vrany wrote:
On 31/07/14 10:45, Marcel Taeumel wrote:
Hi! :)
I am playing around with Animations [1] in the Moose 5.0/Pharo 3.0 image [2]. Nested use of the same mutex seems to freeze the image. Should that work?
No, it should not :-) Use Monitor instead.
Then what's the difference between Semaphore and Mutex in Pharo? Levente
Jan
Best, Marcel
[1] https://github.com/marceltaeumel/animations [2] https://ci.inria.fr/moose/job/moose-5.0/lastSuccessfulBuild/artifact/moose-5...
-- View this message in context: http://forum.world.st/Should-nested-mutexes-work-in-Pharo-3-0-tp4771110.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2014-07-31 14:53 GMT+02:00 Levente Uzonyi <leves@elte.hu>:
On Thu, 31 Jul 2014, Jan Vrany wrote:
On 31/07/14 10:45, Marcel Taeumel wrote:
Hi! :)
I am playing around with Animations [1] in the Moose 5.0/Pharo 3.0 image [2]. Nested use of the same mutex seems to freeze the image. Should that work?
No, it should not :-) Use Monitor instead.
Then what's the difference between Semaphore and Mutex in Pharo?
Mutex are reentrant, Semaphore are not.
Levente
Jan
Best, Marcel
[1] https://github.com/marceltaeumel/animations [2] https://ci.inria.fr/moose/job/moose-5.0/lastSuccessfulBuild/ artifact/moose-5.0.zip
-- View this message in context: http://forum.world.st/Should- nested-mutexes-work-in-Pharo-3-0-tp4771110.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Ah, okay. Just stumpled upon this part of the POSIX specification [1] and thought there could be this recursive property in mutexes for Pharo, too. :) Guess I have to use semaphores then. Best, Marcel [1] http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutexattr_g... -- View this message in context: http://forum.world.st/Should-nested-mutexes-work-in-Pharo-3-0-tp4771110p4771... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On Jul 31, 2014, at 6:55 AM, Jan Vrany <jan.vrany@fit.cvut.cz> wrote:
I am playing around with Animations [1] in the Moose 5.0/Pharo 3.0 image [2]. Nested use of the same mutex seems to freeze the image. Should that work?
No, it should not :-) Use Monitor instead.
+1 nested mutexes should not work not in pharo nor anything else Monitors are for reentering stuff
Okay, I disagree. :) Or I need to rephrase the situation here. ;) I have one process in Pharo that locks the mutex, calls some code and then comes across another piece of code that wants to lock the *same* mutex again in the same process, do some stoff, before return to the original call again. Everything happens in one process (= green thread). As far as I understood, this is the common "recursive" property of a mutex, which could/should work. :) If the Mutex in Pharo does not support recursive locking from within the same process, then it is more like a binary semaphore, right? Best, Marcel -- View this message in context: http://forum.world.st/Should-nested-mutexes-work-in-Pharo-3-0-tp4771110p4771... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Okay, this simple "nesting" works in Pharo: m := Mutex new. m critical: [ Morph new. m critical: [Morph new]]. But this is not exactly the same setting as in Animations. I need to test it a little bit more. :) Best, Marcel -- View this message in context: http://forum.world.st/Should-nested-mutexes-work-in-Pharo-3-0-tp4771110p4771... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Marcel Taeumel wrote:
Okay, I disagree. :) Or I need to rephrase the situation here. ;)
I have one process in Pharo that locks the mutex, calls some code and then comes across another piece of code that wants to lock the *same* mutex again in the same process, do some stoff, before return to the original call again. Everything happens in one process (= green thread). As far as I understood, this is the common "recursive" property of a mutex, which could/should work. :)
If the Mutex in Pharo does not support recursive locking from within the same process, then it is more like a binary semaphore, right?
Recursive locking appears to be provided by the following line activeProcess == owner ifTrue:[^aBlock value]. in Mutex>>critical: btw, if you step into your example, you'll see the mutex is implemented using semaphores. cheers -ben
Okay, this simple "nesting" works in Pharo:
m := Mutex new. m critical: [ Morph new. m critical: [Morph new]].
But this is not exactly the same setting as in Animations. I need to test it a little bit more. :)
Best, Marcel
participants (6)
-
Ben Coman -
Clément Bera -
Jan Vrany -
Levente Uzonyi -
Marcel Taeumel -
Sebastian Sastre