ProcessorScheduler.st
changeset 1575 72fe308c1ba0
parent 1574 b2ad7985b2ea
child 1576 3f6c39471342
equal deleted inserted replaced
1574:b2ad7985b2ea 1575:72fe308c1ba0
  1979      any file descriptors to arrive or a timeout to happen.
  1979      any file descriptors to arrive or a timeout to happen.
  1980      If it makes sense, do some background garbage collection.
  1980      If it makes sense, do some background garbage collection.
  1981      The idle actions are a leftover from previous ST/X releases and will
  1981      The idle actions are a leftover from previous ST/X releases and will
  1982      vanish (installing a low-prio process has the same effect)."
  1982      vanish (installing a low-prio process has the same effect)."
  1983 
  1983 
  1984     |millis doingGC|
  1984     |millis doingGC anySema|
  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.
  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         anySema := false.
  2031             readSemaphoreArray do:[:sema | sema notNil ifTrue:[^ self]].
  2031         readSemaphoreArray do:[:sema | sema notNil ifTrue:[anySema := true]].
  2032             writeSemaphoreArray do:[:sema | sema notNil ifTrue:[^ self]].
  2032         anySema ifFalse:[
       
  2033             writeSemaphoreArray do:[:sema | sema notNil ifTrue:[anySema := true]].
       
  2034         ].
       
  2035         anySema ifFalse:[
  2033             self anyUserProcessAtAll ifFalse:[
  2036             self anyUserProcessAtAll ifFalse:[
  2034                 dispatching := false.
  2037                 dispatching := false.
  2035                 ^ self
  2038                 ^ self
  2036             ]
  2039             ]
  2037         ]
  2040         ].
  2038     ].
  2041     ].
  2039 
  2042 
  2040     OperatingSystem supportsSelect ifFalse:[
  2043     OperatingSystem supportsSelect ifFalse:[
  2041         "SCO instant ShitStation has a bug here,
  2044         "SCO instant ShitStation has a bug here,
  2042          waiting always 1 sec in the select - therefore we delay a bit and
  2045          waiting always 1 sec in the select - therefore we delay a bit and
  2048         OperatingSystem millisecondDelay:50.
  2051         OperatingSystem millisecondDelay:50.
  2049         ^ self
  2052         ^ self
  2050     ].
  2053     ].
  2051 
  2054 
  2052     millis isNil ifTrue:[
  2055     millis isNil ifTrue:[
  2053         exitWhenNoMoreUserProcesses ifTrue:[
  2056         millis := 9999.
  2054             millis := 100
       
  2055         ] ifFalse:[
       
  2056             millis := 9999.
       
  2057         ]
       
  2058     ] ifFalse:[
  2057     ] ifFalse:[
  2059         millis := millis rounded
  2058         millis := millis rounded
  2060     ].
  2059     ].
  2061     self checkForInputWithTimeout:millis
  2060     self checkForInputWithTimeout:millis
  2062 
  2061 
  2063     "Modified: 14.12.1995 / 13:37:46 / stefan"
  2062     "Modified: 14.12.1995 / 13:37:46 / stefan"
  2064     "Modified: 18.7.1996 / 20:30:24 / cg"
  2063     "Modified: 18.7.1996 / 20:40:19 / cg"
  2065 ! !
  2064 ! !
  2066 
  2065 
  2067 !ProcessorScheduler  class methodsFor:'documentation'!
  2066 !ProcessorScheduler  class methodsFor:'documentation'!
  2068 
  2067 
  2069 version
  2068 version
  2070     ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.83 1996-07-18 18:30:43 cg Exp $'
  2069     ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.84 1996-07-18 18:40:39 cg Exp $'
  2071 ! !
  2070 ! !
  2072 ProcessorScheduler initialize!
  2071 ProcessorScheduler initialize!