'From Squeak3.7beta of ''1 April 2004'' [latest update: #5954] on 21 June 2004 at 11:02:57 am'! "Change Set: EnsureEssentialProcesses-nk Date: 21 June 2004 Author: Ned Konz It's possible to kill off the WeakArray finalization process, and it never gets restarted. This can cause many hard-to-diagnose problems. This change set ensures that the WeakArray finalization process is started at every start up. It also shuts down the EventSensor's interruptWatcherProcess and eventTicklerProcess at shutdown time (and starts them at startUp time, of course). (Removed InputSensor class>>startUp from original changeset which was not needed. -dew) "! !InputSensor methodsFor: 'user interrupts' stamp: 'nk 6/21/2004 10:41'! installInterruptWatcher "Initialize the interrupt watcher process. Terminate the old process if any." "Sensor installInterruptWatcher" InterruptWatcherProcess ifNotNil: [InterruptWatcherProcess terminate]. InterruptSemaphore _ Semaphore new. InterruptWatcherProcess _ [self userInterruptWatcher] forkAt: Processor lowIOPriority. self primInterruptSemaphore: InterruptSemaphore.! ! !EventSensor methodsFor: 'initialize' stamp: 'nk 6/21/2004 10:42'! startUp "Run the I/O process" self initialize. self primSetInputSemaphore: (Smalltalk registerExternalObject: inputSemaphore). super startUp. self installEventTickler. Smalltalk isMorphic ifTrue:[self flushAllButDandDEvents]. "Attempt to discover whether the input semaphore is actually being signaled." hasInputSemaphore := false. inputSemaphore initSignals. ! ! !EventSensor methodsFor: 'private' stamp: 'nk 6/21/2004 10:40'! installEventTickler "Initialize the interrupt watcher process. Terminate the old process if any." "Sensor installEventTickler" EventTicklerProcess ifNotNil: [EventTicklerProcess terminate]. EventTicklerProcess _ [self eventTickler] forkAt: Processor lowIOPriority. ! ! !InputSensor class methodsFor: 'system startup' stamp: 'nk 6/21/2004 10:36'! shutDown self default shutDown.! ! !ProcessBrowser methodsFor: 'process list' stamp: 'nk 6/21/2004 09:59'! processNameList "since processList is a WeakArray, we have to strengthen the result" | pw tally | pw _ Smalltalk at: #CPUWatcher ifAbsent: [ ]. tally _ pw ifNotNil: [ pw current ifNotNil: [ pw current tally ] ]. ^ (processList asOrderedCollection copyWithout: nil) collect: [:each | | percent | percent _ tally ifNotNil: [ ((((tally occurrencesOf: each) * 100.0 / tally size) roundTo: 1) asString padded: #left to: 2 with: $ ), '% ' ] ifNil: [ '' ]. percent, (self prettyNameForProcess: each) ] ! ! !SystemDictionary class methodsFor: 'initialization' stamp: 'nk 6/21/2004 10:18'! initialize "SystemDictionary initialize" | oldList | oldList _ StartUpList. StartUpList _ OrderedCollection new. "These get processed from the top down..." #( DisplayScreen Cursor InputSensor ProcessorScheduler "Starts low space watcher and bkground." Delay FileDirectory "Enables file stack dump and opens sources." ShortIntegerArray ShortRunArray CrLfFileStream ) do:[:clsName| Smalltalk at: clsName ifPresent:[:cls| Smalltalk addToStartUpList: cls]. ]. oldList ifNotNil: [oldList do: [:className | Smalltalk at: className ifPresent: [:theClass | Smalltalk addToStartUpList: theClass]]]. #( ImageSegment PasteUpMorph ControlManager ) do:[:clsName| Smalltalk at: clsName ifPresent:[:cls| Smalltalk addToStartUpList: cls]. ]. oldList _ ShutDownList. ShutDownList _ OrderedCollection new. "These get processed from the bottom up..." #( DisplayScreen InputSensor Form ControlManager PasteUpMorph StrikeFont Color FileDirectory Delay SoundPlayer HttpUrl Password PWS MailDB ImageSegment ) do:[:clsName| Smalltalk at: clsName ifPresent:[:cls| Smalltalk addToShutDownList: cls]. ]. oldList ifNotNil: [oldList reverseDo: [:className | Smalltalk at: className ifPresent: [:theClass | Smalltalk addToShutDownList: theClass]]]. ! ! !WeakArray class methodsFor: 'class initialization' stamp: 'nk 6/21/2004 10:22'! initialize "WeakArray initialize" "Do we need to initialize specialObjectsArray?" Smalltalk specialObjectsArray size < 42 ifTrue:[Smalltalk recreateSpecialObjectsArray]. Smalltalk addToStartUpList: self. self restartFinalizationProcess.! ! !WeakArray class methodsFor: 'system startup' stamp: 'nk 6/21/2004 09:22'! startUp: resuming resuming ifFalse: [ ^self ]. self restartFinalizationProcess.! ! !WeakArray class methodsFor: 'private' stamp: 'nk 6/21/2004 10:22'! restartFinalizationProcess "kill any old process, just in case" FinalizationProcess ifNotNil: [FinalizationProcess terminate. FinalizationProcess := nil]. "Check if Finalization is supported by this VM" IsFinalizationSupported := nil. self isFinalizationSupported ifFalse: [^ self]. FinalizationSemaphore := Smalltalk specialObjectsArray at: 42. FinalizationDependents ifNil: [FinalizationDependents := WeakArray new: 10]. FinalizationLock := Semaphore forMutualExclusion. FinalizationProcess := [self finalizationProcess] forkAt: Processor userInterruptPriority! ! WeakArray initialize! !WeakArray class reorganize! ('accessing' addWeakDependent: isFinalizationSupported removeWeakDependent: runningFinalizationProcess) ('class initialization' initialize) ('system startup' startUp:) ('private' finalizationProcess pvtCreateTemporaryObjectIn: restartFinalizationProcess) ! SystemDictionary initialize! !InputSensor reorganize! ('accessing' eventQueue eventQueue: flushAllButDandDEvents) ('buttons' buttons) ('cursor' currentCursor currentCursor: cursorPoint cursorPoint: peekPosition) ('initialize' flushEvents shutDown startUp) ('joystick' joystickButtons: joystickOn: joystickXY: testJoystick:) ('keyboard' flushKeyboard kbdTest keyboard keyboardPeek keyboardPressed) ('modifier keys' anyModifierKeyPressed commandKeyPressed controlKeyPressed leftShiftDown macOptionKeyPressed rawMacOptionKeyPressed shiftPressed) ('mouse' anyButtonPressed blueButtonPressed mouseButtons mousePoint noButtonPressed peekButtons peekMousePt redButtonPressed waitButton waitButtonOrKeyboard waitClickButton waitNoButton yellowButtonPressed) ('tablet' hasTablet tabletExtent tabletPoint tabletPressure tabletTimestamp) ('user interrupts' eventTicklerProcess inputProcess installInterruptWatcher interruptWatcherProcess setInterruptKey: userInterruptWatcher) ('private' characterForKeycode: primCursorLocPut: primCursorLocPutAgain: primInterruptSemaphore: primKbdNext primKbdPeek primMouseButtons primMousePt primReadJoystick: primSetInterruptKey: primTabletGetParameters: primTabletRead:) !