diff -r 87eda283dab1 -r f351744c575f ProcessorScheduler.st --- a/ProcessorScheduler.st Mon Aug 24 18:30:10 1998 +0200 +++ b/ProcessorScheduler.st Mon Aug 24 18:32:06 1998 +0200 @@ -902,6 +902,91 @@ "Modified: / 7.6.1998 / 02:23:56 / cg" ! ! +!ProcessorScheduler methodsFor:'native thread support'! + +immediateInterrupt:why + "{ Pragma: +returnable }" + + "signal from OsThread - switch to scheduler process which will decide + what to do now. Blocking is enabled. + This is only used with win32's native threads." + + |id pri l s| + + OperatingSystem interruptsBlocked ifFalse:[ + MiniDebugger enterWithMessage:'immediateInterrupt with no interruptsBlocked'. + ]. + + (why == 2) ifTrue:[ + s := #wrapWait. + ] ifFalse:[ + (why == 3) ifTrue:[ + s := #osWait. + ] ifFalse:[ + s := #stopped. + ]. + ]. + activeProcess setStateTo:s if:#active. + + pri := activeProcess priority. + l := quiescentProcessLists at:pri. + + "notice: this is slightly faster than putting the if-code into + the ifAbsent block, because [] is a shared cheap block, created at compile time + " + (l isNil or:[(l remove:activeProcess ifAbsent:[]) isNil]) ifTrue:[ + "/ 'Processor [warning]: bad immediateInterrupt: not on run list' errorPrintCR. + MiniDebugger enterWithMessage:'bad immediateInterrupt: not on run list'. + ^ self + ]. +"/ id := scheduler id. +"/ pri := scheduler priority. +"/ scheduler state:#active. +"/ +"/ " +"/ no interrupts now - activeProcess has already been changed +"/ (dont add any message sends here) +"/ " +"/ activeProcess := scheduler. +"/ activeProcessId := id. +"/ currentPriority := pri. + + "Modified: / 24.8.1998 / 18:30:53 / cg" +! + +resumeImmediateInterrupt:id + "{ Pragma: +returnable }" + + "signal from OsThread - resume thread; Blocking is enabled. + This is only used with win32's native threads." + + |index pri aProcess l| + + OperatingSystem interruptsBlocked ifFalse:[ + MiniDebugger enterWithMessage:'resumeImmediateInterrupt with no interruptsBlocked'. + ]. + index := KnownProcessIds identityIndexOf:id. + index ~~ 0 ifTrue:[ + aProcess := KnownProcesses at:index. + aProcess state ~~ #wrapWait ifTrue:[^ self]. + pri := aProcess priority. + l := quiescentProcessLists at:pri. + "if already running, ignore" + l notNil ifTrue:[ + (l identityIndexOf:aProcess) ~~ 0 ifTrue:[ + ^ self + ] + ] ifFalse:[ + l := LinkedList new. + quiescentProcessLists at:pri put:l. + ]. + l addLast:aProcess. + aProcess state:#run. + ]. + + "Modified: / 24.8.1998 / 18:31:08 / cg" +! ! + !ProcessorScheduler methodsFor:'os process handling'! childSignalInterrupt @@ -1059,13 +1144,18 @@ and, make the process runnable " aProcess state ~~ #stopped ifTrue:[ - " - and, make the process runnable - " - self resume:aProcess + aProcess state == #osWait ifTrue:[ + ('Processor [warning]: ignored scheduleForInterrupt:Process ',(aProcess id) printString,' state osWait') errorPrintCR. + "/ self halt. + ] ifFalse:[ + " + and, make the process runnable + " + self resume:aProcess + ] ] - "Modified: 17.6.1996 / 14:40:52 / cg" + "Modified: / 24.8.1998 / 18:31:32 / cg" ! scheduleInterruptActionsOf:aProcess @@ -1607,6 +1697,12 @@ "ignore, if process is already dead" (aProcess isNil or:[aProcess id isNil]) ifTrue:[^ self]. + aProcess state == #osWait ifTrue:[ + 'Processor [warning]: bad resume: state osWait' errorPrintCR. + "/ MiniDebugger enterWithMessage:'bad resume: state osWait'. + ^ self. + ]. + aProcess == activeProcess ifTrue:[ "special handling for waiting schedulers" @@ -1646,7 +1742,7 @@ aProcess state:#run ] - "Modified: 29.7.1996 / 12:07:37 / cg" + "Modified: / 24.8.1998 / 18:28:42 / cg" ! resumeForSingleSend:aProcess @@ -2857,83 +2953,9 @@ "Modified: 18.7.1996 / 20:42:17 / cg" ! ! -!ProcessorScheduler methodsFor:'native thread support'! - -immediateInterrupt:why - "{ Pragma: +returnable }" - - "signal from OsThread - switch to scheduler process which will decide - what to do now. Blocking is enabled " - - |id pri l s| - - OperatingSystem interruptsBlocked ifFalse:[ - MiniDebugger enterWithMessage:'immediateInterrupt with no interruptsBlocked'. - ]. - - "/ (why == 1) ifTrue:[ - "/ s := #osWait. - "/ ] ifFalse:[ - s := #wrapWait. - "/ ]. - activeProcess setStateTo:s if:#active. - - pri := activeProcess priority. - l := quiescentProcessLists at:pri. - - "notice: this is slightly faster than putting the if-code into - the ifAbsent block, because [] is a shared cheap block, created at compile time - " - (l isNil or:[(l remove:activeProcess ifAbsent:[]) isNil]) ifTrue:[ - "/ 'Processor [warning]: bad immediateInterrupt: not on run list' errorPrintCR. - MiniDebugger enterWithMessage:'bad immediateInterrupt: not on run list'. - ^ self - ]. - id := scheduler id. - pri := scheduler priority. - scheduler state:#active. - - " - no interrupts now - activeProcess has already been changed - (dont add any message sends here) - " - activeProcess := scheduler. - activeProcessId := id. - currentPriority := pri. -! - -resumeImmediateInterrupt:id - "{ Pragma: +returnable }" - - "signal from OsThread - resume thread; Blocking is enabled" - - |index pri aProcess l| - - OperatingSystem interruptsBlocked ifFalse:[ - MiniDebugger enterWithMessage:'resumeImmediateInterrupt with no interruptsBlocked'. - ]. - index := KnownProcessIds identityIndexOf:id. - index ~~ 0 ifTrue:[ - aProcess := KnownProcesses at:index. - pri := aProcess priority. - l := quiescentProcessLists at:pri. - "if already running, ignore" - l notNil ifTrue:[ - (l identityIndexOf:aProcess) ~~ 0 ifTrue:[ - ^ self - ] - ] ifFalse:[ - l := LinkedList new. - quiescentProcessLists at:pri put:l. - ]. - l addLast:aProcess. - aProcess state:#run. - ]. -! ! - !ProcessorScheduler class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.160 1998-08-11 14:37:43 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.161 1998-08-24 16:32:06 cg Exp $' ! ! ProcessorScheduler initialize!