[squeak-dev] Re: Setting a preempted process priority glitch

Andreas Raab andreas.raab at gmx.de
Fri May 1 15:45:31 UTC 2009


Igor Stasenko wrote:
> This issue shows, that comment in Process>>#terminate, lying to us:
> 
> "Since the receiver is not the active process, drop its priority to
> rock-bottom so that
> it doesn't accidentally preempt the process that is trying to terminate it."
> priority := 10.

It's actually saying the right thing. What this code is trying to avoid 
is that a process waiting on some semaphore (like a network thread) 
starts "running away" when it receives a signal (we've seen this 
happening in several cases). Contrary to your example the terminating 
process has no wait during which the terminated process could run at 
lower priority. And if the terminated process were at higher priority 
and not currently waiting, then obviously the terminating process would 
not execute. So it all works out.

But the real fix for these issues is atomic suspend, i.e., instead of:

	priority := 10.
	myList ifNotNil: [
		myList remove: self ifAbsent: [].
		"Figure out if the receiver was terminated while waiting on a Semaphore"
		inSema := myList class == Semaphore.
		myList := nil].


this needs to be:

	oldList := self suspend.
	inSema := oldList class == Semaphore.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list