JavaVM.st
branchcvs_MAIN
changeset 3963 f96bd18869e8
parent 3916 f119b43d9ae4
child 3968 a2f749d76588
equal deleted inserted replaced
3962:a02c0cd92786 3963:f96bd18869e8
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1996-2015 by Claus Gittinger
     4  COPYRIGHT (c) 1996-2015 by Claus Gittinger
     3 
     5 
     4  New code and modifications done at SWING Research Group [1]:
     6  New code and modifications done at SWING Research Group [1]:
     5 
     7 
  4173                     with: aJavaContext selector
  4175                     with: aJavaContext selector
  4174                     with: thisProcess id)
  4176                     with: thisProcess id)
  4175             severity:Logger severityTRACE
  4177             severity:Logger severityTRACE
  4176             facility:#JVM.
  4178             facility:#JVM.
  4177     ].
  4179     ].
       
  4180 
  4178     wasBlocked := OperatingSystem blockInterrupts.
  4181     wasBlocked := OperatingSystem blockInterrupts.
  4179 
       
  4180     "/ Ensure any eventual thinlock is inflated here...
  4182     "/ Ensure any eventual thinlock is inflated here...
  4181     someObject getJavaMonitor.
  4183     someObject getJavaMonitor.
  4182 
       
  4183     "/ Now, we're sure that the lock is fat JavaMonitor, enter it
  4184     "/ Now, we're sure that the lock is fat JavaMonitor, enter it
  4184     self enterMonitor:someObject ofProcess:thisProcess.
  4185     self enterMonitor:someObject ofProcess:thisProcess.
  4185 "/    aJavaContext notNil ifTrue:[aJavaContext addMonitor:someObject].
  4186     "/ aJavaContext notNil ifTrue:[aJavaContext addMonitor:someObject].
  4186 
  4187 
  4187     wasBlocked ifFalse:[ OperatingSystem unblockInterrupts ].
  4188     wasBlocked ifFalse:[ OperatingSystem unblockInterrupts ].
  4188 
  4189 
  4189     MonitorTrace ifTrue:[
  4190     MonitorTrace ifTrue:[
  4190         Logger
  4191         Logger
  4219             facility: #JVM.
  4220             facility: #JVM.
  4220     ].
  4221     ].
  4221 
  4222 
  4222     wasBlocked := OperatingSystem blockInterrupts.
  4223     wasBlocked := OperatingSystem blockInterrupts.
  4223     self leaveMonitor: someObject ofProcess: thisProcess.
  4224     self leaveMonitor: someObject ofProcess: thisProcess.
  4224 "/    aJavaContext notNil ifTrue:[aJavaContext removeMonitor: someObject].
  4225     "/ aJavaContext notNil ifTrue:[aJavaContext removeMonitor: someObject].
  4225     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4226     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4226 
  4227 
  4227     MonitorTrace ifTrue: [
  4228     MonitorTrace ifTrue: [
  4228         Logger
  4229         Logger
  4229             log: ('MONEXIT: monitor left for %1 in %2 thread %3'
  4230             log: ('MONEXIT: monitor left for %1 in %2 thread %3'
  4341 
  4342 
  4342 waitOn: obj forTimeout: tmo state: state
  4343 waitOn: obj forTimeout: tmo state: state
  4343     "wait"
  4344     "wait"
  4344 
  4345 
  4345     | wasBlocked  thisProcess  mon |
  4346     | wasBlocked  thisProcess  mon |
       
  4347 
  4346     thisProcess := Processor activeProcess.
  4348     thisProcess := Processor activeProcess.
  4347     thisProcess isInterrupted ifTrue: [
  4349     thisProcess isInterrupted ifTrue: [
  4348         thisProcess clearInterrupted.
  4350         thisProcess clearInterrupted.
  4349         self
  4351         self
  4350             throwInterruptedException: 'process was interrupted before/during wait !!?'
  4352             throwInterruptedException: 'process was interrupted before/during wait !!?'
  4790 
  4792 
  4791 waitFor: sema state: pState timeOut: tmo
  4793 waitFor: sema state: pState timeOut: tmo
  4792     "wait"
  4794     "wait"
  4793 
  4795 
  4794     | wasBlocked  thisProcess  releasedCount  acquiredCount |
  4796     | wasBlocked  thisProcess  releasedCount  acquiredCount |
       
  4797 
  4795     thisProcess := Processor activeProcess.
  4798     thisProcess := Processor activeProcess.
  4796     wasBlocked := OperatingSystem blockInterrupts.
  4799     wasBlocked := OperatingSystem blockInterrupts.
  4797     releasedCount := self countAcquiredMonitorsOfProcess: thisProcess.
  4800     releasedCount := self countAcquiredMonitorsOfProcess: thisProcess.
  4798     (self hasAcquiredMonitorsOfProcess: thisProcess) ifTrue: [
  4801     (self hasAcquiredMonitorsOfProcess: thisProcess) ifTrue: [
  4799         MonitorTrace ifTrue: [
  4802         MonitorTrace ifTrue: [
  4901 !
  4904 !
  4902 
  4905 
  4903 park: process timeout: tout
  4906 park: process timeout: tout
  4904     "A helper for sun.misc.Unsafe.park()"
  4907     "A helper for sun.misc.Unsafe.park()"
  4905 
  4908 
  4906     | blocked sema |
  4909     | wasBlocked sema |
  4907 
  4910 
  4908     blocked := OperatingSystem blockInterrupts.
  4911     wasBlocked := OperatingSystem blockInterrupts.
  4909     ParkUnparkSemaphores isNil ifTrue:[ ParkUnparkSemaphores := Dictionary new ].
  4912     ParkUnparkSemaphores isNil ifTrue:[ ParkUnparkSemaphores := Dictionary new ].
  4910     sema := ParkUnparkSemaphores at: process ifAbsentPut:[Semaphore new].
  4913     sema := ParkUnparkSemaphores at: process ifAbsentPut:[Semaphore new].
  4911     blocked ifFalse:[ OperatingSystem unblockInterrupts ].
  4914     wasBlocked ifFalse:[ OperatingSystem unblockInterrupts ].
  4912 
  4915 
  4913     Logger log: 'parking thread ', process printString severity: Logger severityDEBUG facility: #JVM.
  4916     Logger log: 'parking thread ', process printString severity: Logger severityDEBUG facility: #JVM.
  4914     sema parkWithTimeoutMs: tout.
  4917     sema parkWithTimeoutMs: tout.
  4915     Logger log: 'parked thread ', process printString , ' resumed' severity: Logger severityDEBUG facility: #JVM.
  4918     Logger log: 'parked thread ', process printString , ' resumed' severity: Logger severityDEBUG facility: #JVM.
  4916 
  4919 
  4992 !
  4995 !
  4993 
  4996 
  4994 unpark: process
  4997 unpark: process
  4995     "A helper for sun.misc.Unsafe.unpark()"
  4998     "A helper for sun.misc.Unsafe.unpark()"
  4996 
  4999 
  4997     | blocked sema |
  5000     | wasBlocked sema |
  4998 
  5001 
  4999     blocked := OperatingSystem blockInterrupts.
  5002     wasBlocked := OperatingSystem blockInterrupts.
  5000     ParkUnparkSemaphores isNil ifTrue:[ ParkUnparkSemaphores := Dictionary new ].
  5003     ParkUnparkSemaphores isNil ifTrue:[ ParkUnparkSemaphores := Dictionary new ].
  5001     sema := ParkUnparkSemaphores at: process ifAbsentPut:[Semaphore new].
  5004     sema := ParkUnparkSemaphores at: process ifAbsentPut:[Semaphore new].
  5002     blocked ifFalse:[ OperatingSystem unblockInterrupts ].
  5005     wasBlocked ifFalse:[ OperatingSystem unblockInterrupts ].
  5003 
  5006 
  5004     Logger log: 'unparking thread ', process printString severity: Logger severityDEBUG facility: #JVM.
  5007     Logger log: 'unparking thread ', process printString severity: Logger severityDEBUG facility: #JVM.
  5005     sema signal.
  5008     sema signal.
  5006 
  5009 
  5007     "Created: / 16-08-2012 / 21:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5010     "Created: / 16-08-2012 / 21:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"