Semaphore>>critical: ?

Göran Hultgren gohu at rocketmail.com
Mon Sep 3 12:49:02 UTC 2001


Hi again!

[Snipped some stuff] Mark wrote:
> > If you like, you can use my test:
> > 
> > 100 timesRepeat: [
> > 	| s procs |
> > 	s := Semaphore forMutualExclusion.
> > 	procs := (1 to: 50) collect: [:i |
> > 		[Processor yield. [s critical: []] repeat] forkAt: Processor
> > activeProcess priority - 1].
> > 	procs do: [:p |
> > 		(Delay forMilliseconds: 2) wait.
> > 		p terminate].
> > 	(Delay forMilliseconds: 100) wait.
> > 	s excessSignals = 0 ifTrue: [self error: 'Failure to release critical
> > semaphore']].
> 
> So... you mean this should work with the original #critical:?
> And, I do not really understand your check for failure, if it works shouldn't excessSignals be
> 0?

I tried this (well, not the exact same code but almost) and since it is a mutex the excessSignals
start at 1 and should end there too. So the test is correct.

Anyway, it fails in a recent 3.1a Squeak as predicted both my implementation of #critical: and the
current one. And predictably my implementation fails even easier since I have a larger "window"
between the finish of the block and the signal to the Semaphore.

Ok... well, at this point I will let this go - this is definitely my area...

regards, Göran

=====
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