diff -r 58b6d00013c4 -r de9b98f4a494 Process.st --- a/Process.st Tue Jun 10 12:15:44 2014 +0200 +++ b/Process.st Tue Jun 10 12:20:23 2014 +0200 @@ -17,7 +17,7 @@ emergencySignalHandler suspendActions creatorId processGroupId interruptsDisabled priorityRange exceptionHandlerSet processType environment lookupActivations lookupDisabled' - classVariableNames:'TerminateSignal RestartSignal CoughtSignals' + classVariableNames:'TerminateSignal RestartSignal CaughtSignals' poolDictionaries:'' category:'Kernel-Processes' ! @@ -318,7 +318,7 @@ RestartSignal := RestartProcessRequest. RestartSignal notifierString:'unhandled process restart'. - CoughtSignals := SignalSet + CaughtSignals := SignalSet with:AbortAllOperationRequest with:TerminateProcessRequest with:RestartProcessRequest. @@ -535,7 +535,7 @@ exceptionHandlerSet "retrieve the exceptionHandlerSet, which includes the set of - exceptionHandlers which are cought by the process. + exceptionHandlers which are caught by the process. Initially being empty, this allows for default handlers to be dynamically added/removed from the set of handled exceptions/queries." @@ -590,22 +590,22 @@ priorityRange := anInterval. anInterval notNil ifTrue:[ - lowPri := priorityRange start. - hiPri := priorityRange stop. - (newPrio := prio) isNil ifTrue:[ - newPrio := lowPri - ] ifFalse:[ - prio < lowPri ifTrue:[ - newPrio := lowPri - ] ifFalse:[ - prio > hiPri ifTrue:[ - newPrio := hiPri - ]. - ]. - ]. - newPrio ~~ prio ifTrue:[ - self priority:newPrio - ] + lowPri := priorityRange start. + hiPri := priorityRange stop. + (newPrio := prio) isNil ifTrue:[ + newPrio := lowPri + ] ifFalse:[ + prio < lowPri ifTrue:[ + newPrio := lowPri + ] ifFalse:[ + prio > hiPri ifTrue:[ + newPrio := hiPri + ]. + ]. + ]. + newPrio ~~ prio ifTrue:[ + self priority:newPrio + ] ]. "Modified: / 3.8.1998 / 22:56:05 / cg" @@ -1369,7 +1369,7 @@ "Called by method lookup MOP when an lookup context is to be unwound to cleanup lookup stack" lookupActivations first == lookupObject ifTrue:[ - lookupActivations := lookupActivations second. + lookupActivations := lookupActivations second. ]. "Created: / 04-10-2013 / 10:46:48 / Jan Vrany " @@ -1648,36 +1648,36 @@ |block| (block := startBlock) notNil ifTrue:[ - "/ - "/ just for your convenience ... - "/ - name isNil ifTrue:[ - name := '(' , block displayString , ')' - ]. - restartable ~~ true ifTrue:[startBlock := nil]. - - [ - "/ - "/ handle Process-Termination, Process-Restart and Abort - "/ - CoughtSignals handle:[:ex | - ex creator == RestartProcessRequest ifTrue:[ - ex restart - ]. - ex return - ] do:[ - exceptionHandlerSet isNil ifTrue:[ - exceptionHandlerSet := ExceptionHandlerSet new. - ]. - "/ - "/ block is the one which received the fork some time ago... - "/ - exceptionHandlerSet handleDo:block - ] - ] ensure:[self terminateNoSignal]. + "/ + "/ just for your convenience ... + "/ + name isNil ifTrue:[ + name := '(' , block displayString , ')' + ]. + restartable ~~ true ifTrue:[startBlock := nil]. + + [ + "/ + "/ handle Process-Termination, Process-Restart and Abort + "/ + CaughtSignals handle:[:ex | + ex creator == RestartProcessRequest ifTrue:[ + ex restart + ]. + ex return + ] do:[ + exceptionHandlerSet isNil ifTrue:[ + exceptionHandlerSet := ExceptionHandlerSet new. + ]. + "/ + "/ block is the one which received the fork some time ago... + "/ + exceptionHandlerSet handleDo:block + ] + ] ensure:[self terminateNoSignal]. ] ifFalse:[ - "is this artificial restriction useful ?" - self error:'a process cannot be started twice' mayProceed:true + "is this artificial restriction useful ?" + self error:'a process cannot be started twice' mayProceed:true ] "Modified: / 17.11.2001 / 16:45:32 / cg" @@ -1752,22 +1752,22 @@ suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll]. suspendActions notNil ifTrue:[ - |savedState| - - savedState := state. - state := #aboutToSuspend. - suspendActions do:[:action | action value]. - state ~~ #aboutToSuspend ifTrue:[ - "/ mhmh - one of the suspendActions lead to making me active again; - "/ bail out. - "/ This fixes the Semaphore was signalled, but process did not run error, - "/ which can happen when a process with a suspend action goes into a readWait, - "/ and the suspend action does a thread switch, and the readWait semaphore gets - "/ signalled before we come back here. Then the semaphore wakeup will have already - "/ place me back into the run state, so I should not go into a suspend below. - ^ self. - ]. - state := savedState. + |savedState| + + savedState := state. + state := #aboutToSuspend. + suspendActions do:[:action | action value]. + state ~~ #aboutToSuspend ifTrue:[ + "/ mhmh - one of the suspendActions lead to making me active again; + "/ bail out. + "/ This fixes the Semaphore was signalled, but process did not run error, + "/ which can happen when a process with a suspend action goes into a readWait, + "/ and the suspend action does a thread switch, and the readWait semaphore gets + "/ signalled before we come back here. Then the semaphore wakeup will have already + "/ place me back into the run state, so I should not go into a suspend below. + ^ self. + ]. + state := savedState. ]. " @@ -1779,7 +1779,7 @@ (state == #active or:[state == #run or:[aStateSymbol == #stopped]]) ifTrue:[ - state := aStateSymbol. + state := aStateSymbol. ]. Processor suspend:self ! @@ -1798,48 +1798,48 @@ |wasBlocked| Processor activeProcess ~~ self ifTrue:[ - wasBlocked := OperatingSystem blockInterrupts. - [ - state == #osWait ifTrue:[ - self terminateNoSignal. - ^ self. - ]. - - "if the receiver had no chance to execute yet, - it can be shot down without a signal" - - self suspendedContext isNil ifTrue:[ - self terminateNoSignal. - ^ self - ] - ] ensure:[ - wasBlocked ifFalse:[OperatingSystem unblockInterrupts] - ]. - - "register an interrupt action and resume that process" - self interruptWith:[ - NoHandlerError handle:[:ex | - ex exception creator == TerminateProcessRequest ifTrue:[ - ex return. - ]. - ex reject. - ] do:[ - TerminateProcessRequest raise. - ]. - self terminateNoSignal. - ]. + wasBlocked := OperatingSystem blockInterrupts. + [ + state == #osWait ifTrue:[ + self terminateNoSignal. + ^ self. + ]. + + "if the receiver had no chance to execute yet, + it can be shot down without a signal" + + self suspendedContext isNil ifTrue:[ + self terminateNoSignal. + ^ self + ] + ] ensure:[ + wasBlocked ifFalse:[OperatingSystem unblockInterrupts] + ]. + + "register an interrupt action and resume that process" + self interruptWith:[ + NoHandlerError handle:[:ex | + ex exception creator == TerminateProcessRequest ifTrue:[ + ex return. + ]. + ex reject. + ] do:[ + TerminateProcessRequest raise. + ]. + self terminateNoSignal. + ]. ] ifFalse:[ - "terminating myself" - - NoHandlerError handle:[:ex | - ex exception creator == TerminateProcessRequest ifTrue:[ - ex return. - ]. - ex reject. - ] do:[ - TerminateProcessRequest raise. - ]. - self terminateNoSignal. + "terminating myself" + + NoHandlerError handle:[:ex | + ex exception creator == TerminateProcessRequest ifTrue:[ + ex return. + ]. + ex reject. + ] do:[ + TerminateProcessRequest raise. + ]. + self terminateNoSignal. ] "Modified: / 24.8.1998 / 18:29:46 / cg" @@ -2090,22 +2090,22 @@ |var oldValue result| environment isNil ifTrue:[ - environment := IdentityDictionary new + environment := IdentityDictionary new ]. var := environment at:variableNameSymbol ifAbsent:nil. var isNil ifTrue:[ - var := ValueHolder new. - environment at:variableNameSymbol put:var. + var := ValueHolder new. + environment at:variableNameSymbol put:var. ]. oldValue := var value. [ - var value:aValue. - result := aBlock value. + var value:aValue. + result := aBlock value. ] ensure:[ - oldValue isNil - ifTrue:[ environment removeKey:variableNameSymbol] - ifFalse:[ var value:oldValue ] + oldValue isNil + ifTrue:[ environment removeKey:variableNameSymbol] + ifFalse:[ var value:oldValue ] ]. ^ result @@ -2115,17 +2115,17 @@ printIt := [ Transcript showCR:'foo is now ',(Processor activeProcess threadVariableValueOf:#foo) printString ]. Processor activeProcess - withThreadVariable:#foo - boundTo:1234 - do:[ - printIt value. - Processor activeProcess - withThreadVariable:#foo - boundTo:2345 - do:[ - printIt value - ]. - ] + withThreadVariable:#foo + boundTo:1234 + do:[ + printIt value. + Processor activeProcess + withThreadVariable:#foo + boundTo:2345 + do:[ + printIt value + ]. + ] " ! ! @@ -2133,7 +2133,7 @@ version_CVS - ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.184 2014-05-13 12:18:03 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.185 2014-06-10 10:20:23 cg Exp $' ! version_SVN