UnixOperatingSystem.st
changeset 16464 a695c2af61fd
parent 16417 88b61e714dd0
child 16481 cbecb6681a12
equal deleted inserted replaced
16463:2b3728727f5e 16464:a695c2af61fd
 11106      The other threads are not affected by the wait."
 11106      The other threads are not affected by the wait."
 11107 
 11107 
 11108     |inputSema hasData wasBlocked|
 11108     |inputSema hasData wasBlocked|
 11109 
 11109 
 11110     fd isNil ifTrue:[^ self error:#errorNotOpen].
 11110     fd isNil ifTrue:[^ self error:#errorNotOpen].
       
 11111     self canReadWithoutBlocking ifTrue:[
       
 11112         ^ false.
       
 11113     ].
 11111 
 11114 
 11112     wasBlocked := OperatingSystem blockInterrupts.
 11115     wasBlocked := OperatingSystem blockInterrupts.
 11113     hasData := self canReadWithoutBlocking.
 11116     inputSema := Semaphore new name:'readWait'.
 11114     hasData ifFalse:[
 11117     [
 11115 	inputSema := Semaphore new name:'readWait'.
 11118         timeout notNil ifTrue:[
 11116 	[
 11119             Processor signal:inputSema afterMilliseconds:timeout
 11117 	    timeout notNil ifTrue:[
 11120         ].
 11118 		Processor signal:inputSema afterMilliseconds:timeout
 11121         Processor signal:inputSema onInput:fd.
 11119 	    ].
 11122         Processor activeProcess state:#ioWait.
 11120 	    Processor signal:inputSema onInput:fd.
 11123         inputSema wait.
 11121 	    Processor activeProcess state:#ioWait.
 11124         hasData := self canReadWithoutBlocking.
 11122 	    inputSema wait.
 11125     ] ifCurtailed:[
 11123 	    Processor disableSemaphore:inputSema.
 11126         Processor disableSemaphore:inputSema.
 11124 	    hasData := self canReadWithoutBlocking.
 11127         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 11125 	] ifCurtailed:[
       
 11126 	    Processor disableSemaphore:inputSema.
       
 11127 	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
       
 11128 	]
       
 11129     ].
 11128     ].
 11130     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 11129     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 11131     ^ hasData not
 11130     ^ hasData not
 11132 !
 11131 !
 11133 
 11132 
 11139      The other threads are not affected by the wait."
 11138      The other threads are not affected by the wait."
 11140 
 11139 
 11141     |outputSema canWrite wasBlocked|
 11140     |outputSema canWrite wasBlocked|
 11142 
 11141 
 11143     fd isNil ifTrue:[^ self error:#errorNotOpen].
 11142     fd isNil ifTrue:[^ self error:#errorNotOpen].
       
 11143     self canWriteWithoutBlocking ifTrue:[
       
 11144         ^ false.
       
 11145     ].
 11144 
 11146 
 11145     wasBlocked := OperatingSystem blockInterrupts.
 11147     wasBlocked := OperatingSystem blockInterrupts.
 11146     canWrite := self canWriteWithoutBlocking.
 11148     outputSema := Semaphore new name:'writeWait'.
 11147     canWrite ifFalse:[
 11149     [
 11148 	outputSema := Semaphore new name:'writeWait'.
 11150         timeout notNil ifTrue:[
 11149 	[
 11151             Processor signal:outputSema afterMilliseconds:timeout
 11150 	    timeout notNil ifTrue:[
 11152         ].
 11151 		Processor signal:outputSema afterMilliseconds:timeout
 11153         Processor signal:outputSema onOutput:fd.
 11152 	    ].
 11154         Processor activeProcess state:#ioWait.
 11153 	    Processor signal:outputSema onOutput:fd.
 11155         outputSema wait.
 11154 	    Processor activeProcess state:#ioWait.
 11156         canWrite := self canWriteWithoutBlocking.
 11155 	    outputSema wait.
 11157     ] ifCurtailed:[
 11156 	    Processor disableSemaphore:outputSema.
 11158         Processor disableSemaphore:outputSema.
 11157 	    canWrite := self canWriteWithoutBlocking.
 11159         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 11158 	] ifCurtailed:[
       
 11159 	    Processor disableSemaphore:outputSema.
       
 11160 	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
       
 11161 	]
       
 11162     ].
 11160     ].
 11163     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 11161     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
 11164     ^ canWrite not
 11162     ^ canWrite not
 11165 ! !
 11163 ! !
 11166 
 11164 
 13270 ! !
 13268 ! !
 13271 
 13269 
 13272 !UnixOperatingSystem class methodsFor:'documentation'!
 13270 !UnixOperatingSystem class methodsFor:'documentation'!
 13273 
 13271 
 13274 version
 13272 version
 13275     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.361 2014-05-11 14:06:09 cg Exp $'
 13273     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.362 2014-05-16 07:02:44 stefan Exp $'
 13276 !
 13274 !
 13277 
 13275 
 13278 version_CVS
 13276 version_CVS
 13279     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.361 2014-05-11 14:06:09 cg Exp $'
 13277     ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.362 2014-05-16 07:02:44 stefan Exp $'
 13280 ! !
 13278 ! !
 13281 
 13279 
 13282 
 13280 
 13283 UnixOperatingSystem initialize!
 13281 UnixOperatingSystem initialize!
 13284 UnixOperatingSystem::FileDescriptorHandle initialize!
 13282 UnixOperatingSystem::FileDescriptorHandle initialize!