1759 Answer true, if a reschedule is required, false if not." |
1759 Answer true, if a reschedule is required, false if not." |
1760 |
1760 |
1761 |l s pri wasBlocked| |
1761 |l s pri wasBlocked| |
1762 |
1762 |
1763 "ignore, if process is already dead" |
1763 "ignore, if process is already dead" |
1764 (aProcess isNil or:[aProcess id isNil]) ifTrue:[^ false]. |
1764 (aProcess isNil or:[aProcess isDead]) ifTrue:[^ false]. |
1765 |
1765 |
1766 s := aProcess state. |
1766 s := aProcess state. |
1767 s == #osWait ifTrue:[ |
1767 s == #osWait ifTrue:[ |
1768 'Processor [warning]: bad resume: #osWait' errorPrintCR. |
1768 'Processor [warning]: bad resume: #osWait' errorPrintCR. |
1769 "/ MiniDebugger enterWithMessage:'bad resume: state osWait'. |
1769 "/ MiniDebugger enterWithMessage:'bad resume: state osWait'. |
1770 ^ false. |
1770 ^ false. |
1771 ]. |
1771 ]. |
1772 s == #stopped ifTrue:[ |
1772 s == #stopped ifTrue:[ |
1773 "by definition, stopped processes cannot be resumed" |
1773 "by definition, stopped processes cannot be resumed" |
1774 ^ false. |
1774 ^ false. |
1775 ]. |
1775 ]. |
1776 |
1776 |
1777 aProcess == activeProcess ifTrue:[ |
1777 aProcess == activeProcess ifTrue:[ |
1778 "special handling for waiting schedulers" |
1778 "special handling for waiting schedulers" |
1779 aProcess == scheduler ifTrue:[ |
1779 aProcess == scheduler ifTrue:[ |
1780 suspendScheduler := false. |
1780 suspendScheduler := false. |
1781 ]. |
1781 ]. |
1782 ^ false |
1782 ^ false |
1783 ]. |
1783 ]. |
1784 |
1784 |
1785 wasBlocked := OperatingSystem blockInterrupts. |
1785 wasBlocked := OperatingSystem blockInterrupts. |
1786 |
1786 |
1787 pri := aProcess priority. |
1787 pri := aProcess priority. |
1788 |
1788 |
1789 l := quiescentProcessLists at:pri. |
1789 l := quiescentProcessLists at:pri. |
1790 "if already running, ignore" |
1790 "if already running, ignore" |
1791 l notNil ifTrue:[ |
1791 l notNil ifTrue:[ |
1792 (l identityIndexOf:aProcess) ~~ 0 ifTrue:[ |
1792 (l identityIndexOf:aProcess) ~~ 0 ifTrue:[ |
1793 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1793 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1794 ^ false |
1794 ^ false |
1795 ] |
1795 ] |
1796 ] ifFalse:[ |
1796 ] ifFalse:[ |
1797 l := LinkedList new. |
1797 l := LinkedList new. |
1798 quiescentProcessLists at:pri put:l. |
1798 quiescentProcessLists at:pri put:l. |
1799 ]. |
1799 ]. |
1800 l addLast:aProcess. |
1800 l addLast:aProcess. |
1801 aProcess state:#run. |
1801 aProcess state:#run. |
1802 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1802 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1803 |
1803 |
1804 pri > currentPriority ifTrue:[ |
1804 pri > currentPriority ifTrue:[ |
1805 "must reschedule" |
1805 "must reschedule" |
1806 ^ true. |
1806 ^ true. |
1807 ]. |
1807 ]. |
1808 |
1808 |
1809 timeSliceNeededSemaphore notNil ifTrue:[ |
1809 timeSliceNeededSemaphore notNil ifTrue:[ |
1810 "/ tell timeslicer, that some work might be needed... |
1810 "/ tell timeslicer, that some work might be needed... |
1811 timeSliceNeededSemaphore signalIf. |
1811 timeSliceNeededSemaphore signalIf. |
1812 ]. |
1812 ]. |
1813 ^ false. |
1813 ^ false. |
1814 |
1814 |
1815 "Modified: / 29.7.1996 / 12:07:37 / cg" |
1815 "Modified: / 29.7.1996 / 12:07:37 / cg" |
1816 "Created: / 4.2.1998 / 20:58:28 / cg" |
1816 "Created: / 4.2.1998 / 20:58:28 / cg" |
3236 If there were many, the list should be kept sorted ... keeping deltas |
3236 If there were many, the list should be kept sorted ... keeping deltas |
3237 to next (as in Unix kernel)" |
3237 to next (as in Unix kernel)" |
3238 |
3238 |
3239 n := timeoutArray size. |
3239 n := timeoutArray size. |
3240 1 to:n do:[:index | |
3240 1 to:n do:[:index | |
3241 aTime := timeoutArray at:index. |
3241 aTime := timeoutArray at:index. |
3242 aTime notNil ifTrue:[ |
3242 aTime notNil ifTrue:[ |
3243 now isNil ifTrue:[ |
3243 now isNil ifTrue:[ |
3244 now := OperatingSystem getMillisecondTime. |
3244 now := OperatingSystem getMillisecondTime. |
3245 ]. |
3245 ]. |
3246 delta := OperatingSystem millisecondTimeDeltaBetween:aTime and:now. |
3246 delta := OperatingSystem millisecondTimeDeltaBetween:aTime and:now. |
3247 delta <= 0 ifTrue:[ |
3247 delta <= 0 ifTrue:[ |
3248 ^ 0. |
3248 ^ 0. |
3249 ]. |
3249 ]. |
3250 minDelta isNil ifTrue:[ |
3250 minDelta isNil ifTrue:[ |
3251 minDelta := delta |
3251 minDelta := delta |
3252 ] ifFalse:[ |
3252 ] ifFalse:[ |
3253 minDelta := minDelta min:delta |
3253 minDelta := minDelta min:delta |
3254 ] |
3254 ] |
3255 ] |
3255 ] |
|
3256 ]. |
|
3257 minDelta isNil ifTrue:[ |
|
3258 "this is safe, since always called with interruptsBlocked" |
|
3259 anyTimeouts := false. |
3256 ]. |
3260 ]. |
3257 |
3261 |
3258 ^ minDelta |
3262 ^ minDelta |
3259 ! |
3263 ! |
3260 |
3264 |