Author: Patrick Rein <patrick.r...@student.hpi.uni-potsdam.de> Branch: stmgc-c7 Changeset: r851:3f97fdcac997 Date: 2014-07-03 15:26 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/3f97fdcac997/
Log: Added OSLock class to access rthread.lock and corresponding primitives. diff --git a/images/Squeak4.5-12568.changes b/images/Squeak4.5-12568.changes --- a/images/Squeak4.5-12568.changes +++ b/images/Squeak4.5-12568.changes @@ -758,4 +758,4 @@ self fieldNew: swapField. ]. - ^ self field! ! ----QUIT----{22 May 2014 . 3:33:07 pm} Squeak4.5-12568.image priorSource: 93437! ----STARTUP----{22 May 2014 . 3:33:13 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:33'! gameLifeOfLife STMSimulation benchmark.! ! ----QUIT----{22 May 2014 . 3:34:03 pm} Squeak4.5-12568.image priorSource: 110218! ----STARTUP----{22 May 2014 . 3:34:57 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:35'! gameOfLife STMSimulation benchmark.! ! Integer removeSelector: #gameLifeOfLife! ----QUIT----{22 May 2014 . 3:35:14 pm} Squeak4.5-12568.image priorSource: 110526! ----STARTUP----{22 May 2014 . 3:36:22 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:36' prior: 33665224! gameOfLife STMSimulation benchmark2.! ! ----QUIT----{22 May 2014 . 3:36:45 pm} Squeak4.5-12568.image priorSource: 110873! ----STARTUP----{22 May 2014 . 3:36:49 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT----{22 May 2014 . 3:36:53 pm} Squeak4.5-12568.image priorSource: 111195! ----STARTUP----{22 May 2014 . 3:36:56 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:37' prior: 33665587! gameOfLife SPyVM print: STMSimulation benchmark2.! ! ----QUIT----{22 May 2014 . 3:37:32 pm} Squeak4.5-12568.image priorSource: 111392! ----STARTUP----{22 May 2014 . 3:38:15 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT----{22 May 2014 . 3:38:35 pm} Squeak4.5-12568.image priorSource: 111727! ----STARTUP----{2 June 2014 . 12:57:18 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: 'benchmarks' stamp: 'hh 6/2/2014 12:58'! benchStmParallelWarmed 10 timesRepeat: [SPyVM print: (self benchStmParallel)].! ! ----QUIT----{2 June 2014 . 12:58:21 pm} Squeak4.5-12568.image priorSource: 111924! \ No newline at end of file + ^ self field! ! ----QUIT----{22 May 2014 . 3:33:07 pm} Squeak4.5-12568.image priorSource: 93437! ----STARTUP----{22 May 2014 . 3:33:13 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:33'! gameLifeOfLife STMSimulation benchmark.! ! ----QUIT----{22 May 2014 . 3:34:03 pm} Squeak4.5-12568.image priorSource: 110218! ----STARTUP----{22 May 2014 . 3:34:57 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:35'! gameOfLife STMSimulation benchmark.! ! Integer removeSelector: #gameLifeOfLife! ----QUIT----{22 May 2014 . 3:35:14 pm} Squeak4.5-12568.image priorSource: 110526! ----STARTUP----{22 May 2014 . 3:36:22 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:36' prior: 33665224! gameOfLife STMSimulation benchmark2.! ! ----QUIT----{22 May 2014 . 3:36:45 pm} Squeak4.5-12568.image priorSource: 110873! ----STARTUP----{22 May 2014 . 3:36:49 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT----{22 May 2014 . 3:36:53 pm} Squeak4.5-12568.image priorSource: 111195! ----STARTUP----{22 May 2014 . 3:36:56 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 15:37' prior: 33665587! gameOfLife SPyVM print: STMSimulation benchmark2.! ! ----QUIT----{22 May 2014 . 3:37:32 pm} Squeak4.5-12568.image priorSource: 111392! ----STARTUP----{22 May 2014 . 3:38:15 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT----{22 May 2014 . 3:38:35 pm} Squeak4.5-12568.image priorSource: 111727! ----STARTUP----{2 June 2014 . 12:57:18 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! !Integer methodsFor: 'benchmarks' stamp: 'hh 6/2/2014 12:58'! benchStmParallelWarmed 10 timesRepeat: [SPyVM print: (self benchStmParallel)].! ! ----QUIT----{2 June 2014 . 12:58:21 pm} Squeak4.5-12568.image priorSource: 111924! ----STARTUP----{26 June 2014 . 2:47:09 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! 'From Squeak4.4 of 28 April 2013 [latest update: #12627] on 26 June 2014 at 2:46:54 pm'! Object subclass: #OSLock instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Kernel-STM'! Object subclass: #OSLock instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Kernel-STM'! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 14:25'! lock <primitive: 792>! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 14:26'! release <primitive: 793>! ! ----End fileIn of a stream----! 'From Squeak4.4 of 28 April 2013 [latest update: #12627] on 26 June 2014 at 2:46:45 pm'! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 14:48' prior: 33647508! parallelForkTest | p | FileStream stdout nextPutAll: 'starting stm process.'. p := [ 1 + 1. ] parallelFork. p wait! ! ----End fileIn of D:\code\python\spy-vm\lang-smalltalk\images\Integer-parallelForkTest.st----! ----QUIT----{26 June 2014 . 2:47:49 pm} Squeak4.5-12568.image priorSource: 112268! ----STARTUP----{26 June 2014 . 2:49:11 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! 'From Squeak4.4 of 28 April 2013 [latest update: #12627] on 26 June 2014 at 2:46:45 pm'! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 5/22/2014 14:48' prior: 33667646! parallelForkTest | p | FileStream stdout nextPutAll: 'starting stm process.'. p := [ 1 + 1. ] parallelFork. p wait! ! ----End fileIn of D:\code\python\spy-vm\lang-smalltalk\images\Integer-parallelForkTest.st----! ----SNAPSHOT----{26 June 2014 . 2:49:57 pm} Squeak4.5-12568.image priorSource: 113431! ----QUIT----{26 June 2014 . 2:50 pm} Squeak4.5-12568.image priorSource: 114022! ----STARTUP----{26 June 2014 . 2:52:02 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! 'From Squeak4.4 of 28 April 2013 [latest update: #12627] on 26 June 2014 at 2:51:52 pm'! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 14:43'! osLockTest | lock process1 process2 process2lock | lock := OSLock new. lock lock. process2lock := OSLock new. process2lock lock. process1 := [ SPyVM print: 'First process start'. lock lock. process2lock release. SPyVM print: 'First process after lock'. lock release. ] parallelFork . process2 := [ SPyVM print: 'Second process start'. process2lock lock. lock lock. SPyVM print: 'Second process after lock'. process2lock release. lock release. ] parallelFork . SPyVM print: 'Processes initialized.'. lock release. process1 wait. process2 wait.! ! ----End fileIn of a stream----! ----QUIT----{26 June 2014 . 2:53:18 pm} Squeak4.5-12568.image priorSource: 114110! ----STARTUP----{26 June 2014 . 3:02:03 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:02'! osLockEasyTest | lock | lock := OSLock new. lock lock. lock release. SPyVM print: 'Survived lock.'! ! ----QUIT----{26 June 2014 . 3:02:52 pm} Squeak4.5-12568.image priorSource: 115096! ----STARTUP----{26 June 2014 . 3:03:40 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 15:04' prior: 33667310! lock <primitive: 792> SPyVM print: '* STM Process did not fork *' , Character cr. self primitiveFailed. self resume! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 15:04' prior: 33667409! release <primitive: 793> SPyVM print: '* STM Process did not fork *' , Character cr. self primitiveFailed. self resume! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 15:04' prior: 33670408! release <primitive: 793> SPyVM print: '* OS Lock could not be released *' , Character cr. self primitiveFailed. self resume! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 15:04' prior: 33670196! lock <primitive: 792> SPyVM print: '* OS Lock could not be locked *' , Character cr. self primitiveFailed. self resume! ! ----QUIT----{26 June 2014 . 3:04:45 pm} Squeak4.5-12568.image priorSource: 115476! ----STARTUP----{26 June 2014 . 3:08:07 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:08' prior: 33669797! osLockEasyTest | lock | lock := OSLock new. lock lock. SPyVM print: 'Survived lock.'! ! ----QUIT----{26 June 2014 . 3:08:24 pm} Squeak4.5-12568.image priorSource: 116537! ----STARTUP----{26 June 2014 . 3:09:05 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:09' prior: 33671254! osLockEasyTest | lock | lock := OSLock new. lock lock. lock release. SPyVM print: 'Survived lock.'! ! ----QUIT----{26 June 2014 . 3:09:17 pm} Squeak4.5-12568.image priorSource: 116916! ----STARTUP----{26 June 2014 . 3:57:38 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:57' prior: 33671633! osLockEasyTest | lock | lock := OSLock new. lock lock. SPyVM print: 'Survived lock.' lock release. SPyVM print: 'Survived lock.'! ! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:58' prior: 33672027! osLockEasyTest | lock | lock := OSLock new. lock lock. SPyVM print: 'Survived lock.'. lock release. SPyVM print: 'Survived lock.'. ^ self! ! ----QUIT----{26 June 2014 . 3:58:58 pm} Squeak4.5-12568.image priorSource: 117310! ----STARTUP----{26 June 2014 . 3:59:21 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:59' prior: 33672253! osLockEasyTest | lock | lock := OSLock new. lock lock. SPyVM print: 'Survived locking.'. lock release. SPyVM print: 'Survived releasing.'. ^ self! ! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'pre 6/26/2014 15:59' prior: 33672690! osLockEasyTest | lock1 | lock1 := OSLock new. lock1 lock. SPyVM print: 'Survived locking.'. lock1 release. SPyVM print: 'Survived releasing.'. ^ self! ! ----QUIT----{26 June 2014 . 4:00 pm} Squeak4.5-12568.image priorSource: 117973! ----STARTUP----{26 June 2014 . 4:07:56 pm} as D:\code\python\spy-vm\lang-smalltalk\images\Squeak4.5-12568.image! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 16:09' prior: 33670843! lock self internalLock ! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 16:09'! internalLock <primitive: 792> SPyVM print: '* OS Lock could not be locked *' , Character cr. self primitiveFailed. self resume! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 16:09'! internalRelease <primitive: 793> SPyVM print: '* OS Lock could not be released *' , Character cr. self primitiveFailed. self resume! ! !OSLock methodsFor: 'as yet unclassified' stamp: 'pre 6/26/2014 16:09' prior: 33670623! release self internalRelease! ! ----QUIT----{26 June 2014 . 4:09:34 pm} Squeak4.5-12568.image priorSource: 118668! \ No newline at end of file diff --git a/images/Squeak4.5-12568.image b/images/Squeak4.5-12568.image index 0d24c0b0506552d59e3dd4db7be72f7e565a8d7c..6628e9cf95b4860c2c865166b07278b10aec9b80 GIT binary patch [cut] diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -1335,6 +1335,10 @@ STM_ATOMIC_ENTER = 1302 # 790 STM_ATOMIC_LEAVE = 1303 # 791 +# OS Lock Primitives +OS_LOCK_LOCK = 1304 # 792 +OS_LOCK_RELEASE = 1305 # 793 + @expose_primitive(BLOCK_COPY, unwrap_spec=[object, int]) def func(interp, s_frame, w_context, argcnt): @@ -1542,6 +1546,26 @@ rstm.decrement_atomic() +@expose_primitive(OS_LOCK_LOCK, unwrap_spec=[object], no_result=True) +def func(interp, s_frame, w_rcvr): + from rpython.rlib import rthread + + if not isinstance(w_rcvr, model.W_PointersObject): + raise PrimitiveFailedError("OS_LOCK_LOCK primitive was not called on an OSLock Object") + + lock_shadow = w_rcvr.as_special_get_shadow(interp.space, shadow.OSLockShadow) + lock_shadow.os_lock() + +@expose_primitive(OS_LOCK_RELEASE, unwrap_spec=[object], no_result=True) +def func(interp, s_frame, w_rcvr): + from rpython.rlib import rthread + + if not isinstance(w_rcvr, model.W_PointersObject): + raise PrimitiveFailedError("OS_LOCK_LOCK primitive was not called on an OSLock Object") + + lock_shadow = w_rcvr.as_special_get_shadow(interp.space, shadow.OSLockShadow) + lock_shadow.os_release() + # ___________________________________________________________________________ # BlockClosure Primitives diff --git a/spyvm/shadow.py b/spyvm/shadow.py --- a/spyvm/shadow.py +++ b/spyvm/shadow.py @@ -1142,4 +1142,17 @@ return lock_result def signal(self): - self.lock.release() \ No newline at end of file + self.lock.release() + +class OSLockShadow(AbstractShadow): + + def __init__(self, space, w_self): + AbstractShadow.__init__(self, space, w_self) + self.intern_lock = rthread.allocate_lock() + + def os_lock(self): + self.intern_lock.acquire(True) + + def os_release(self): + self.intern_lock.release() + _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit