ProcSched.st
changeset 3245 863c0a09f5a2
parent 3116 e535e4e266dd
child 3246 092deb605639
equal deleted inserted replaced
3244:9ba0abc1d217 3245:863c0a09f5a2
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
       
    13 'From Smalltalk/X, Version:3.1.9 on 5-aug-1997 at 4:51:43 pm'                   !
       
    14 
    12 
    15 Object subclass:#ProcessorScheduler
    13 Object subclass:#ProcessorScheduler
    16 	instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess
    14 	instanceVariableNames:'quiescentProcessLists scheduler zombie activeProcess
    17 		activeProcessId currentPriority readFdArray readSemaphoreArray
    15 		activeProcessId currentPriority readFdArray readSemaphoreArray
    18 		readCheckArray writeFdArray writeSemaphoreArray timeoutArray
    16 		readCheckArray writeFdArray writeSemaphoreArray timeoutArray
  2228     now := OperatingSystem getMillisecondTime.
  2226     now := OperatingSystem getMillisecondTime.
  2229     blocksToEvaluate := nil.
  2227     blocksToEvaluate := nil.
  2230     n := timeoutArray size.
  2228     n := timeoutArray size.
  2231     anyTimeouts := false.
  2229     anyTimeouts := false.
  2232     1 to:n do:[:index |
  2230     1 to:n do:[:index |
  2233 	aTime := timeoutArray at:index.
  2231         aTime := timeoutArray at:index.
  2234 	aTime notNil ifTrue:[
  2232         aTime notNil ifTrue:[
  2235 	    (OperatingSystem millisecondTime:aTime isAfter:now) ifFalse:[
  2233             (OperatingSystem millisecondTime:aTime isAfter:now) ifFalse:[
  2236 		"this one should be triggered"
  2234                 "this one should be triggered"
  2237 
  2235 
  2238 		sema := timeoutSemaphoreArray at:index.
  2236                 sema := timeoutSemaphoreArray at:index.
  2239 		sema notNil ifTrue:[
  2237                 sema notNil ifTrue:[
  2240 		    sema signalOnce.
  2238                     sema signalOnce.
  2241 		    timeoutSemaphoreArray at:index put:nil
  2239                     timeoutSemaphoreArray at:index put:nil
  2242 		] ifFalse:[
  2240                 ] ifFalse:[
  2243 		    "to support pure-events"
  2241                     "to support pure-events"
  2244 		    block := timeoutActionArray at:index.
  2242                     block := timeoutActionArray at:index.
  2245 		    block notNil ifTrue:[
  2243                     block notNil ifTrue:[
  2246 			blocksToEvaluate isNil ifTrue:[
  2244                         blocksToEvaluate isNil ifTrue:[
  2247 			    blocksToEvaluate := OrderedCollection new:10.
  2245                             blocksToEvaluate := OrderedCollection new:10.
  2248 			    processes := OrderedCollection new:10.
  2246                             processes := OrderedCollection new:10.
  2249 			].
  2247                         ].
  2250 			blocksToEvaluate add:block.
  2248                         blocksToEvaluate add:block.
  2251 			processes add:(timeoutProcessArray at:index).
  2249                         processes add:(timeoutProcessArray at:index).
  2252 			timeoutActionArray at:index put:nil.
  2250                         timeoutActionArray at:index put:nil.
  2253 			timeoutProcessArray at:index put:nil.
  2251                         timeoutProcessArray at:index put:nil.
  2254 		    ]
  2252                     ]
  2255 		].
  2253                 ].
  2256 		timeoutArray at:index put:nil.
  2254                 timeoutArray at:index put:nil.
  2257 	    ] ifTrue:[
  2255             ] ifTrue:[
  2258 		anyTimeouts := true
  2256                 anyTimeouts := true
  2259 	    ]
  2257             ]
  2260 	]
  2258         ]
  2261     ].
  2259     ].
  2262 
  2260 
  2263     blocksToEvaluate notNil ifTrue:[
  2261     blocksToEvaluate notNil ifTrue:[
  2264 	blocksToEvaluate keysAndValuesDo:[:index :block |
  2262         blocksToEvaluate keysAndValuesDo:[:index :block |
  2265 	    |p|
  2263             |p|
  2266 
  2264 
  2267 	    p := processes at:index.
  2265             p := processes at:index.
  2268 	    (p isNil or:[p == scheduler or:[PureEventDriven]]) ifTrue:[
  2266             (p isNil or:[p == scheduler or:[PureEventDriven]]) ifTrue:[
  2269 		block value
  2267                 block value
  2270 	    ] ifFalse:[
  2268             ] ifFalse:[
  2271 		p interruptWith:block
  2269                 p isDead ifTrue:[
  2272 	    ]
  2270                     ('ProcessorScheduler [warning]: cannot evaluate timedBlock for dead process: ''' , p name , '''') infoPrintCR.
  2273 	]
  2271                     ('ProcessorScheduler [warning]: the timedBlock is: ' , block displayString) infoPrintCR.
       
  2272                 ] ifFalse:[
       
  2273                     p interruptWith:block
       
  2274                 ]
       
  2275             ]
       
  2276         ]
  2274     ]
  2277     ]
       
  2278 
       
  2279     "Modified: / 29.1.1998 / 17:02:25 / cg"
  2275 !
  2280 !
  2276 
  2281 
  2277 removeTimedBlock:aBlock
  2282 removeTimedBlock:aBlock
  2278     "remove the argument, aBlock from the list of time-sceduled-blocks."
  2283     "remove the argument, aBlock from the list of time-sceduled-blocks."
  2279 
  2284 
  2606 ! !
  2611 ! !
  2607 
  2612 
  2608 !ProcessorScheduler class methodsFor:'documentation'!
  2613 !ProcessorScheduler class methodsFor:'documentation'!
  2609 
  2614 
  2610 version
  2615 version
  2611     ^ '$Header: /cvs/stx/stx/libbasic/Attic/ProcSched.st,v 1.141 1997-11-20 18:29:40 cg Exp $'
  2616     ^ '$Header: /cvs/stx/stx/libbasic/Attic/ProcSched.st,v 1.142 1998-01-29 16:03:01 cg Exp $'
  2612 ! !
  2617 ! !
  2613 ProcessorScheduler initialize!
  2618 ProcessorScheduler initialize!