1983 |
1983 |
1984 |millis doingGC| |
1984 |millis doingGC| |
1985 |
1985 |
1986 doingGC := true. |
1986 doingGC := true. |
1987 [doingGC] whileTrue:[ |
1987 [doingGC] whileTrue:[ |
1988 anyTimeouts ifTrue:[ |
1988 anyTimeouts ifTrue:[ |
1989 millis := self timeToNextTimeout. |
1989 millis := self timeToNextTimeout. |
1990 (millis notNil and:[millis <= 0]) ifTrue:[ |
1990 (millis notNil and:[millis <= 0]) ifTrue:[ |
1991 ^ self "oops - hurry up checking" |
1991 ^ self "oops - hurry up checking" |
1992 ]. |
1992 ]. |
1993 ]. |
1993 ]. |
1994 |
1994 |
1995 " |
1995 " |
1996 if its worth doing, collect a bit of garbage; |
1996 if its worth doing, collect a bit of garbage; |
1997 but not, if a backgroundCollector is active |
1997 but not, if a backgroundCollector is active |
1998 " |
1998 " |
1999 ObjectMemory backgroundCollectorRunning ifTrue:[ |
1999 ObjectMemory backgroundCollectorRunning ifTrue:[ |
2000 doingGC := false |
2000 doingGC := false |
2001 ] ifFalse:[ |
2001 ] ifFalse:[ |
2002 doingGC := ObjectMemory gcStepIfUseful. |
2002 doingGC := ObjectMemory gcStepIfUseful. |
2003 ]. |
2003 ]. |
2004 |
2004 |
2005 "then do idle actions" |
2005 "then do idle actions" |
2006 (idleActions notNil and:[idleActions size ~~ 0]) ifTrue:[ |
2006 (idleActions notNil and:[idleActions size ~~ 0]) ifTrue:[ |
2007 idleActions do:[:aBlock | |
2007 idleActions do:[:aBlock | |
2008 aBlock value. |
2008 aBlock value. |
2009 ]. |
2009 ]. |
2010 ^ self "go back checking" |
2010 ^ self "go back checking" |
2011 ]. |
2011 ]. |
2012 |
2012 |
2013 doingGC ifTrue:[ |
2013 doingGC ifTrue:[ |
2014 (self checkForInputWithTimeout:0) ifTrue:[ |
2014 (self checkForInputWithTimeout:0) ifTrue:[ |
2015 ^ self "go back checking" |
2015 ^ self "go back checking" |
2016 ] |
2016 ] |
2017 ] |
2017 ] |
2018 ]. |
2018 ]. |
2019 |
2019 |
2020 "/ |
2020 "/ |
2021 "/ absolutely nothing to do - simply wait |
2021 "/ absolutely nothing to do - simply wait |
2022 "/ |
2022 "/ |
2023 exitWhenNoMoreUserProcesses ifTrue:[ |
2023 exitWhenNoMoreUserProcesses ifTrue:[ |
2024 "/ check if there are any processes at all |
2024 "/ check if there are any processes at all |
2025 "/ stop dispatching if there is none |
2025 "/ stop dispatching if there is none |
2026 "/ (and millis is nil, which means that no timeout blocks are present) |
2026 "/ (and millis is nil, which means that no timeout blocks are present) |
2027 "/ and no readSemaphores are present (which means that noone is waiting for input) |
2027 "/ and no readSemaphores are present (which means that noone is waiting for input) |
2028 "/ and no writeSemaphores are present |
2028 "/ and no writeSemaphores are present |
2029 |
2029 |
2030 millis isNil ifTrue:[ |
2030 millis isNil ifTrue:[ |
2031 readSemaphoreArray do:[:sema | sema notNil ifTrue:[^ self]]. |
2031 readSemaphoreArray do:[:sema | sema notNil ifTrue:[^ self]]. |
2032 writeSemaphoreArray do:[:sema | sema notNil ifTrue:[^ self]]. |
2032 writeSemaphoreArray do:[:sema | sema notNil ifTrue:[^ self]]. |
2033 self anyUserProcessAtAll ifFalse:[ |
2033 self anyUserProcessAtAll ifFalse:[ |
2034 dispatching := false. |
2034 dispatching := false. |
2035 ^ self |
2035 ^ self |
2036 ] |
2036 ] |
2037 ] |
2037 ] |
2038 ]. |
2038 ]. |
2039 |
2039 |
2040 OperatingSystem supportsSelect ifFalse:[ |
2040 OperatingSystem supportsSelect ifFalse:[ |
2041 "SCO instant ShitStation has a bug here, |
2041 "SCO instant ShitStation has a bug here, |
2042 waiting always 1 sec in the select - therefore we delay a bit and |
2042 waiting always 1 sec in the select - therefore we delay a bit and |
2043 return - effectively polling in 50ms cycles |
2043 return - effectively polling in 50ms cycles |
2044 " |
2044 " |
2045 (self checkForInputWithTimeout:0) ifTrue:[ |
2045 (self checkForInputWithTimeout:0) ifTrue:[ |
2046 ^ self "go back checking" |
2046 ^ self "go back checking" |
2047 ]. |
2047 ]. |
2048 OperatingSystem millisecondDelay:50. |
2048 OperatingSystem millisecondDelay:50. |
2049 ^ self |
2049 ^ self |
2050 ]. |
2050 ]. |
2051 |
2051 |
2052 millis isNil ifTrue:[ |
2052 millis isNil ifTrue:[ |
2053 millis := 9999. |
2053 exitWhenNoMoreUserProcesses ifTrue:[ |
|
2054 millis := 100 |
|
2055 ] ifFalse:[ |
|
2056 millis := 9999. |
|
2057 ] |
2054 ] ifFalse:[ |
2058 ] ifFalse:[ |
2055 millis := millis rounded |
2059 millis := millis rounded |
2056 ]. |
2060 ]. |
2057 self checkForInputWithTimeout:millis |
2061 self checkForInputWithTimeout:millis |
2058 |
2062 |
2059 "Modified: 14.12.1995 / 13:37:46 / stefan" |
2063 "Modified: 14.12.1995 / 13:37:46 / stefan" |
|
2064 "Modified: 18.7.1996 / 20:30:24 / cg" |
2060 ! ! |
2065 ! ! |
2061 |
2066 |
2062 !ProcessorScheduler class methodsFor:'documentation'! |
2067 !ProcessorScheduler class methodsFor:'documentation'! |
2063 |
2068 |
2064 version |
2069 version |
2065 ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.82 1996-07-18 18:13:54 cg Exp $' |
2070 ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.83 1996-07-18 18:30:43 cg Exp $' |
2066 ! ! |
2071 ! ! |
2067 ProcessorScheduler initialize! |
2072 ProcessorScheduler initialize! |