<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks Jaromir! At GitHub now.<br>
<br>
Cheers,<br>
<br>
On 1/19/2023 3:46 PM, Jaromir Matas via Cuis-dev wrote:
<blockquote
cite="mid:PH7PR12MB798760E3E676A32DD29F26D0EEC49@PH7PR12MB7987.namprd12.prod.outlook.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Calibri Light";
panose-1:2 15 3 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
{mso-style-priority:1;
margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";
color:black;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal">Hi Juan,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m enclosing process and semaphore tests I
owe you, illustrating the new #suspend semantics and some more
process tests to cover borderline termination cases (single
context stack, two ensure contexts on top of each other and
such).</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best,</p>
<p class="MsoNormal">Jaromir</p>
<p class="MsoNoSpacing"><span lang="CS">--</span></p>
<p class="MsoNoSpacing"><strong><span style="font-family:
"Calibri Light",sans-serif; color: rgb(51, 51,
51); font-weight: normal;">Jaromír Matas</span></strong><span
style="font-family: "Calibri Light",sans-serif;
color: rgb(85, 85, 85);"><o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="font-family: "Calibri
Light",sans-serif; color: rgb(46, 117, 182);"><a class="moz-txt-link-abbreviated" href="mailto:mail@jaromir.net">mail@jaromir.net</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(143, 170, 220);"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border-right: medium none; border-width: 1pt medium
medium; border-style: solid none none; border-color: rgb(225,
225, 225) -moz-use-text-color -moz-use-text-color; padding:
3pt 0in 0in;">
<p class="MsoNormal" style="border: medium none; padding:
0in;"><b>From: </b><a moz-do-not-send="true"
href="mailto:cuis-dev@lists.cuis.st">Jaromir Matas via
Cuis-dev</a><br>
<b>Sent: </b>Thursday, January 19, 2023 12:25<br>
<b>To: </b><a moz-do-not-send="true"
href="mailto:juan@cuis.st">Juan Vuletich</a>; <a
moz-do-not-send="true"
href="mailto:cuis-dev@lists.cuis.st">
Discussion of Cuis Smalltalk</a><br>
<b>Cc: </b><a moz-do-not-send="true"
href="mailto:mail@jaromir.net">Jaromir Matas</a><br>
<b>Subject: </b>Re: [Cuis-dev] Follow-up: #terminate and
#suspend update</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Juan,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve observed the debugger to pop up all of
a sudden a few times when working with the Process Browser.
The root cause seems to be my #isDone method:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">isDone<o:p></o:p></p>
<p class="MsoNormal"> "Answer if the receiver has
no unexecuted code left."<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> self isDead ifTrue:
[^true].<o:p></o:p></p>
<p class="MsoNormal"> self isBottomContext
ifTrue: [^self atEnd].<o:p></o:p></p>
<p class="MsoNormal"> self atEnd ifTrue: [^self
sender isDone].<o:p></o:p></p>
<p class="MsoNormal"> ^false<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The second line checks if the sender
variable is nil and hence the third line assumes the sender is
not nil – however it may still be nil if the method
computation is preempted and the higher priority process being
checked terminates in the meantime.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here’s my improved version (also enclosed):<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">isDone<o:p></o:p></p>
<p class="MsoNormal"> "Answer if the receiver has
no unexecuted code left."<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> ^sender ifNil: [self
isDeadOrAtEnd] ifNotNil: [:ctx | ctx isDone]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I think this should work as expected
because ifNil:ifNotNil: is inlined (not a send).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">PS: as a side-effect the ProcessorTest
suite now works fine consistently; before, some of the tests
failed occasionally (on my Win10/Intel machine).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best,<o:p></o:p></p>
<p class="MsoNormal">Jaromir<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNoSpacing"><span lang="CS">--</span></p>
<p class="MsoNoSpacing"><strong><span style="font-family:
"Calibri Light",sans-serif; color: rgb(51, 51,
51); font-weight: normal;">Jaromír Matas</span></strong><span
style="font-family: "Calibri Light",sans-serif;
color: rgb(85, 85, 85);"><o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="font-family: "Calibri
Light",sans-serif; color: rgb(46, 117, 182);"><a class="moz-txt-link-abbreviated" href="mailto:mail@jaromir.net">mail@jaromir.net</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: rgb(143, 170, 220);"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border-right: medium none; border-width: 1pt medium
medium; border-style: solid none none; border-color: rgb(225,
225, 225) -moz-use-text-color -moz-use-text-color; padding:
3pt 0in 0in;">
<p class="MsoNormal"><b>From: </b><a moz-do-not-send="true"
href="mailto:juan@cuis.st">Juan Vuletich</a><br>
<b>Sent: </b>Tuesday, September 6, 2022 16:25<br>
<b>To: </b><a moz-do-not-send="true"
href="mailto:cuis-dev@lists.cuis.st">Discussion of Cuis
Smalltalk</a><br>
<b>Cc: </b><a moz-do-not-send="true"
href="mailto:mail@jaromir.net">Jaromir Matas</a><br>
<b>Subject: </b>Re: [Cuis-dev] #terminate and #suspend
update<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color: black;">Hi Jaromir,<br>
<br>
On 8/27/2022 7:12 AM, Jaromir Matas via Cuis-dev wrote: <o:p></o:p></span></p>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;">
<p class="MsoNormal"><span style="color: black;">Hi Juan,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">> There is
one problem left. #isTerminated will always answer false
if #suspend primitive failed and old primitive 88 fallback
method is called. I just pushed to github update #5458 to
address this. Please check it carefully. Maybe you prefer
a different solution, I'll be happy to review and
integrate it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">Oops, I
forgot to mention the backward compatibility consideration
but you caught it :) (meaning: to be able to run new
images with older VMs, not only older images with the new
VM). Squeak decided to maintain only its ability to run
older images with the new VM - so no change in
#isTerminated in Squeak; however I agree with you that
"fixing" #isTerminated is worth the effort provided the
fix is pretty easy.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">I'm enclosing
my original suggestion for #isTerminated; I think the
semantics is very similar to your version (checking
whether the remaining context chain has anything useful
left) except one thing: Your version allows a process with
its suspended context's pc = nil to be considered not
terminated. My understanding was: if a process's suspended
context's pc is nil, it implies the process would be
considered terminated. Is this right or would you define
'being terminated' differently?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">Check this
example:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">ctx _ []
asContextWithSender: [] asContext.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">p _ Process
forContext: ctx priority: 40.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">ctx pc: nil.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">p
isTerminated. "answers false in your version and true in
mine"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">I already
noticed a while ago my previous version of #isTerminated
failed to catch pc = nil in a process's suspended context
and evaluate the process as 'terminated'. I wonder now
what definition of 'terminated' state is actually 'the
right one'.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom: 12pt;"><span
style="color: black;"><br>
I had assumed there would always be sender frames. I believe
my code worked correctly unless there were no sender frames
of the frame with pc=nil. In any case, your version is more
robust and nicer code. I just integrated it. Thanks!<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;">
<p class="MsoNormal"><span style="color: black;">Another
question: in the example above - how do you look at the
bytecodes of ctx? In Squeak the Explorer shows the
bytecodes right away but in Cuis I have to open an extra
inspector for 'method' and look at 'allBytecodes', right?
<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom: 12pt;"><span
style="color: black;"><br>
Yes. You are right. The explorer could be improved, to
behave like Squeak's in this case. If you happen to have a
couple of hours to hack this, it would be useful.<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;">
<p class="MsoNormal"><span style="color: black;">In Squeak the
process p answers true to #isTerminated even without
nilling its pc, which is expected because each of the two
contexts consists only of a single instruction, a return.
But in Cuis I'm not sure how come the answer is false; I
suspect I've got confused by the different implementation
of Context / ContextPart in Squeak/Cuis. Here's what I
mean:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">ctx _ []
asContextWithSender: [] asContext.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">p _ Process
forContext: ctx priority: 40.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">p
isTerminated. "answers false in Cuis and true in Squeak
because ctx atEnd differs"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom: 12pt;"><span
style="color: black;"><br>
Just tried the example above, and it answers false in Squeak
6.0 alpha 21576 on my Intel Mac. Maybe this has changed
recently? Perhaps it needs fixing in both environments.<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;">
<p class="MsoNormal"><span style="color: black;">... while
this works the same in both:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">ctx _ [1]
asContextWithSender: [] asContext.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">p _ Process
forContext: ctx priority: 40.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">p
isTerminated. "answers false in both Cuis and Squeak
because ctx is not atEnd"<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom: 12pt;"><span
style="color: black;"><br>
Yes it does.<br>
<br>
<o:p></o:p></span></p>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;">
<p class="MsoNormal"><span style="color: black;">Thank you for
your advice.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">Best regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;">Jaromir<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="color: black;" lang="CS">--</span><span
style="color: black;"><o:p></o:p></span></p>
<p class="MsoNoSpacing"><strong><span style="font-family:
"Calibri Light",sans-serif; font-weight:
normal;">Jaromír Matas</span></strong><span
style="color: black;"><o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="color: black;"><a
moz-do-not-send="true" href="mailto:mail@jaromir.net">mail@jaromir.net</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color: black;"> <o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom: 12pt;"><span
style="color: black;"><br>
Thanks,<o:p></o:p></span></p>
<pre>-- </pre>
<pre>Juan Vuletich</pre>
<pre>cuis.st</pre>
<pre>github.com/jvuletich</pre>
<pre>researchgate.net/profile/Juan-Vuletich</pre>
<pre>independent.academia.edu/JuanVuletich</pre>
<pre>patents.justia.com/inventor/juan-manuel-vuletich</pre>
<pre>linkedin.com/in/juan-vuletich-75611b3</pre>
<pre>twitter.com/JuanVuletich</pre>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New"; color: black;"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
</body>
</html>