Semaphore>>critical: ?

Stephen Pair spair at advantive.com
Mon Sep 3 02:40:46 UTC 2001


This is one of the first things I have to take care of every time I
start a project in Squeak...actually, to avoid creating side effects, I
usually add a new method called #safeCritical: instead of changing
#critical:.  For a long time, #ensure: had some bugs, but now that they
seem to be resolved, it's probably time to change #critical:.

- Stephen

> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org 
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On 
> Behalf Of Gvran Hultgren
> Sent: Sunday, September 02, 2001 12:27 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Semaphore>>critical: ?
> 
> 
> Hi guys!
> 
> I am hacking away on a Flow based client/server thingy and 
> needed to use a Semaphore as a mutex. So I did something like this:
> 
> myMutex critical: [ ...code code... ^self ...code code...]
> 
> ...and oops, got bitten by the fact that the Semaphore does 
> not get signalled when I have a return in my critical code 
> block! Of course, it was simple to rewrite the code without 
> returns but...
> 
> Is there any particular reason (performance etc) that 
> prevents us from changing the implementation of #critical: to 
> this (thus not missing to signal the Semaphore)?:
> 
> critical: mutuallyExcludedBlock 
> 	"Evaluate mutuallyExcludedBlock only if the receiver is 
> not currently in 
> 	the process of running the critical: message. If the 
> receiver is, evaluate 
> 	mutuallyExcludedBlock after the other critical: message 
> is finished."
> 
> 	self wait.
> 	^mutuallyExcludedBlock ensure: [self signal]
> 
> 
> The funny thing is that this seems to work EXCEPT for one 
> Unit test I have which seems to "hang" on the "self signal" 
> part above. Funny enough, if I alt-. it and then just 
> "proceed" it moves on!
> 
> Obviously I am missing some piece of the puzzle, right? In 
> any case this should perhaps be mentioned in the comment to #critical:
> 
> regards, Göran
> 
> PS. This is in a rather old image pdated to 2915 with JMM's 
> Flow and SUnit 2.7.1. DS
> 
> =====
> Göran Hultgren, goran.hultgren at bluefish.se
> GSM: +46 70 3933950, http://www.bluefish.se
> "Department of Redundancy department." -- ThinkGeek
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with 
> Yahoo! Messenger http://im.yahoo.com
> 
> 





More information about the Squeak-dev mailing list