stuck in critical section (Monitor)

Ross Boylan RossBoylan at stanfordalumni.org
Sat Apr 20 00:18:01 UTC 2002


I have gotten in a jam with critical sections, and wonder if anyone
could help me understand what is happening and how to fix it.  I am
using Andreas Raab's Monitor class, which blocks access to other
processes while permitting recursive access from the locking process.
Some of my questions probably don't require knowing its details.

Symptoms: I dragged and dropped something to start an operation, and
the display froze.  The mouse was not visible, and clicking produced
no action.  The CPU was at 0.

It may matter that before all this I got some error about an out of
bounds index from a UIish process, and abandonned the debugger.  I
also brought up a process inspector.  I have a background process that
updates some things, and I was concerned I had killed it.  It did not
appear in the process inspector, suggesting that I did.

I was able to use the emergency interrupt, which brought up two
windows.  One was a new process window, the other my code executing in
the critical section. While these were up the mouse worked.  I tried
manually stepping through the critical section, reseting some values,
sending signals... But the system kept freezing.  So I did several
emergency interrupts.

The process inspector now shows 6 Processes as UndefinedObject>>doIt
with ProcessScheduler>>terminateActive at the top of the stack (which
consists only of terminateActive and the UndefinedObject>>doIt that is
executing the command.  They are at thisContext removeSelf suspend.

My suspicion is these arose from the boxes that popped up when I hit
emergency interrupt.  I hit abandon to try to kill them, and perhaps
their death is blocked by the critical section.  Is that likely?  Is
there any way to get rid of them?

As to the main event, the key Monitor method is
enter
	"Enter the monitor. Return true if the receiver was owned by the active process, false otherwise."
	| doWait process wasOwned |
	[doWait _ false.
	accessLock critical:[
		process _ Processor activeProcess.
		wasOwned _ process == owner.
		owner 
			ifNil:[owner _ process]
			ifNotNil:[doWait _ wasOwned not].
		waiting _ waiting + 1.
	].
	doWait] whileTrue:[waitSemaphore wait].
	^wasOwned

waiting shows a value of 196653 (which is clearly excessive) and the
owner values seem not to match the active process.



More information about the Squeak-dev mailing list