<div dir="ltr">Hi Both,<div><br></div><div> apologies for not responding sooner. I have been trying to release new VMs (done, announcement soon), and have been sick. So use either 207,208 & 209, or 150, 151 and 152. Let me have the code and I can integrate it.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 15, 2016 at 7:08 AM, Denis Kudriashov <span dir="ltr"><<a href="mailto:dionisiydk@gmail.com" target="_blank">dionisiydk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br><div dir="ltr">Hi Ben.<div><br></div><div>Do you commit your changes?</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-05 8:34 GMT+01:00 Ben Coman <span dir="ltr"><<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br>
On Fri, Feb 5, 2016 at 12:16 AM, Denis Kudriashov <<a href="mailto:dionisiydk@gmail.com" target="_blank">dionisiydk@gmail.com</a>> wrote:<br>
><br>
> Hi.<br>
><br>
> We already discuss it in another thread. And I want to make little conclusion.<br>
><br>
> I propose new lock primitives #acquireLock and #tryAcquireLock. They should be based on existed ownership primitives 186 and 187 but with inverted logic.<br>
><br>
> acquireLock should return true if lock was established by this call. It should return false if lock was already established by current process.<br>
><br>
> tryAcquireLock should doing same as acquireLock. But if lock already acquired by another process primitive should return nil immediately without waiting.<br>
><br>
> Eliot, do you already implemented it?<br>
> if you have no time yet could you say me new primitive numbers? And I will try it myself.<br>
><br>
> It will be nice to get new prims for Pharo5 release.<br>
><br>
> Best regards,<br>
> Denis<br>
><br>
<br>
<br>
</div></div>Following instructions at <a href="https://github.com/pharo-project/pharo-vm" rel="noreferrer" target="_blank">https://github.com/pharo-project/pharo-vm</a><br>
(btw I'm on 32-bit Debian Jessie)<br>
<br>
git clone <a href="https://github.com/pharo-project/pharo-vm.git" rel="noreferrer" target="_blank">https://github.com/pharo-project/pharo-vm.git</a><br>
cd pharo-vm<br>
cd image && ./newImage.sh<br>
./pharo-ui generator.image<br>
PharoVMSpur32Builder buildUnix32.<br>
cd ../build<br>
bash build.sh<br>
../results/pharo #Needs a spur image<br>
<br>
mkdir ../spurImage & cd ../spurImage<br>
curl <a href="http://get.pharo.org/50" rel="noreferrer" target="_blank">get.pharo.org/50</a> | bash<br>
cp ../image/pharo-vm/PharoV40.sources .<br>
cd ../build<br>
<br>
bash build.sh<br>
../results/pharo ../spurImage/Pharo.image<br>
<br>
------------<br>
../image/pharo-ui ../image/generator.image<br>
<br>
searched for implementors of primitiveEnterCriticalSection<br>
<br>
In CoInterpreterPrimitives<br>
duplicated primitiveEnterCriticalSection as primitiveAquireOwnedLock<br>
duplicated primitiveExitCriticalSection as primitiveReleaseOwnedLock<br>
<br>
senders of primitiveEnterCriticalSection found...<br>
StackInterpreter>>initializePrimitiveTable<br>
where I saw...(150 159 primitiveFail)<br>
so for experiment (first time ever playing with this table)<br>
I tried...<br>
(150 primitiveAquireOwnedLock)<br>
(151 primitiveReleaseOwnedLock)<br>
<br>
PharoVMSpur32Builder buildUnix32.<br>
<br>
bash build.sh<br>
../results/pharo ../spurImage/Pharo.image<br>
<br>
-----------------------<br>
Loaded Eliot's CriticalSection.st from [1]...<br>
[1] <a href="http://forum.world.st/Where-to-get-Monitor-implementation-based-on-primitives-td4869758.html" rel="noreferrer" target="_blank">http://forum.world.st/Where-to-get-Monitor-implementation-based-on-primitives-td4869758.html</a><br>
<br>
>From Pharo5Inbox cherrypicked your<br>
SLICE-Issue-17373-Mutex-should-be-based-on-VM-primitives-and-implement-critical-methods-from-Semaphore--DenisKudryashov.10<br>
* all of OwnedLock as OwnedLock186<br>
* Mutex>>criticalNew: as NewMutex186>>critical:<br>
* Mutex>>initialize as NewMutex186>>initialize<br>
<br>
Copied OwnedLock186 & NewMutex186<br>
to OwnedLock150 & NewMutex150.<br>
<br>
OwnwedLock150>>acquire<br>
<primitive: 150><br>
<br>
OwnwedLock150>>release<br>
<primitive: 151><br>
<br>
NewMutex150>>initialize<br>
super initialize.<br>
lock := OwnedLock150 new<br>
<br>
NewMutex150>>critical: aBlock<br>
^[<br>
lock acquire.<br>
aBlock value<br>
] ensure: [lock release].<br>
<br>
Adapted performance tests from [1]...<br>
<br>
{Mutex. Monitor. CriticalSection. NewMutex186. NewMutex150} collect:<br>
[:csClass | | n |<br>
n := 0.<br>
cs := csClass new.<br>
([cs critical: [n := n + 1]. cs critical: [n := n + 1]. cs critical:<br>
[n := n + 1]. cs critical: [n := n + 1]. cs critical: [n := n + 1].<br>
cs critical: [n := n - 1]. cs critical: [n := n - 1]. cs critical: [n<br>
:= n - 1]. cs critical: [n := n - 1]. cs critical: [n := n - 1].<br>
n ] bench),' -> ' , cs class name ]<br>
<br>
which sorted gave...<br>
'264,486 per second -> Mutex'<br>
'405,653 per second -> Monitor'<br>
'516,199 per second -> NewMutex186'<br>
'520,167 per second -> NewMutex150'<br>
'686,169 per second -> CriticalSection'<br>
<br>
Yay! I added (err, copied) my first primitive.<br>
</blockquote></div><br></div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div>