<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><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;}
.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>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Christoph,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Precisely; I like to use this example instead:</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">                p := [Semaphore new wait] fork.</p>
<p class="MsoNormal">                Processor yield.</p>
<p class="MsoNormal">                p suspend.</p>
<p class="MsoNormal">                p resume.</p>
<p class="MsoNormal">                Processor yield.</p>
<p class="MsoNormal">                {p isTerminated. p isBlocked}    "should answer #(false true)"</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">For some reason the example with <span style="font-size:12.0pt;color:black">
Process forBlock: produces ‘Error: resume fails’ in 5.3. If you make it a test, that would be great; I’ve only added testRevisedSuspendExpectations but it is a good idea to test suspend+resume behavior as well.</span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">> <span style="font-size:12.0pt;color:black">Revises #suspend to remember any semaphore or monitor that the receiver has been waiting for and restore the waiting state in #resume (the old behavior is available via #suspendAndUnblock).<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Apologies for nitpicking: “remember” is not exactly what really happens, #suspend ‘simply’ returns process’s pc one instruction (i.e. the send that invoked the wait) back; so the next resume (which may never happen if you e.g. terminate)
 just executes the send again.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Eliot’s comment in #suspend expresses this nicely; maybe take it from there…</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[if a process] was on some condition variable (Semaphore, Mutex) [then] back up its pc to the send that invoked the wait state the process entered.  Hence when the process resumes it will reenter the wait state.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve read somewhere ‘official’ a short and exact description what suspend is supposed to do (not ANSI, somewhere else but can’t remember where) and this Eliot’s implementation does exactly that.</p>
<p class="MsoNormal">Thanks,<br>
Jaromir</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de">Thiede, Christoph</a><br>
<b>Sent: </b>Thursday, June 16, 2022 15:23<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org">The general-purpose Squeak developers list</a><br>
<b>Subject: </b>Re: [squeak-dev] New #suspend semantics</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="divtagdefaultwrapper">
<div id="divtagdefaultwrapper">
<p><span style="font-size:12.0pt;color:black">Hi Jaromir,<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p><span style="font-size:12.0pt;color:black">thanks a lot for the summary!<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p><span style="font-size:12.0pt;color:black">Translating this to code for my own understanding:<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">p := Process forBlock: [Semaphore new wait].<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">p resume.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Processor yield.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">p suspend.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">p resume.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Processor yield.<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">{p isBlocked. p isTerminated}<o:p></o:p></span></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p><span style="font-size:12.0pt;color:black">has answered #(false true) in the past;<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black">and now answers #(true false).<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p><span style="font-size:12.0pt;color:black">> Alas, I don't seem to be able to squeeze it into one sentence or even less ;)<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Hm, I will try this:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Revises #suspend to remember any semaphore or monitor that the receiver has been waiting for and restore the waiting state in #resume (the old behavior is available via #suspendAndUnblock).<o:p></o:p></span></p>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">My question is answered then. :-)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">---<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Please apologize that I did not read the entire linked thread. We tend to write so much that the pure reading time for this thread (let alone any comprehension) would be close to 20 minutes. =D<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">One last quick question: Will there be tests for #suspendAndUnblock? Maybe something like my above example?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Best,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Christoph<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><img border="0" width="694" height="2" style="width:7.2291in;height:.0208in" id="Horizontal_x0020_Line_x0020_1" src="cid:image001.png@01D8819B.573D9FC0"></span><span style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">Von:</span></b><span style="color:black"> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Jaromir Matas <mail@jaromir.net><br>
<b>Gesendet:</b> Montag, 13. Juni 2022 08:45 Uhr<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] New #suspend semantics</span><span style="font-size:12.0pt;color:black">
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"> <o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p><span style="color:black">Hi Christoph,<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">The difference between the new #suspend using suspend primitive 578 and the previous one using primitive 88 is this:<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">Previously, if you suspended a process waiting on a semaphore or mutex the process was removed from the semaphore or mutex; subsequent #resume would let the process continue as if the process had never been waiting.<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">The new suspend with primitive 578 not only removes the process from the semaphore or mutex but backs it up one instruction, i.e. before the wait send, and thus a subsequent #resume will allow the process go back to the wait on
 the semaphore or mutex, i.e. to the same state as before the suspension.<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">One of the adverse effects of the previous behavior was #critical sections could have been entered multiple times regardless of the ownership of the condition variable.<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">The previous behavior have been used (or misused) to cheaply escape a condition variable; for backward compatibility the old behavior has been preserved in #suspendAndUnblock.<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">Here's more: http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-December/217831.html<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">Alas, I don't seem to be able to squeeze it into one sentence or even less ;)<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">Best,<o:p></o:p></span></p>
<p><span style="color:black">Jaromir<o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span lang="CS" style="color:black">--</span><span style="color:black"><o:p></o:p></span></p>
<p><strong><span style="font-family:"Calibri Light",sans-serif;color:#333333;font-weight:normal">Jaromír Matas</span></strong><span style="color:black"><o:p></o:p></span></p>
<p><span style="font-family:"Calibri Light",sans-serif;color:#2E75B6">mail@jaromir.net</span><span style="color:black"><o:p></o:p></span></p>
<p><span style="color:black"> <o:p></o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p><b><span style="color:black">From: </span></b><span style="color:black"><a href="mailto:christoph.thiede@student.hpi.uni-potsdam.de">christoph.thiede@student.hpi.uni-potsdam.de</a><br>
<b>Sent: </b>Sunday, June 12, 2022 21:45<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org">squeak-dev@lists.squeakfoundation.org</a><br>
<b>Subject: </b>[squeak-dev] New #suspend semantics<o:p></o:p></span></p>
</div>
<p><span style="color:black"> <o:p></o:p></span></p>
<p><span style="color:black">Hi Jaromír,<br>
<br>
as I'm currently updating the release notes, I'm trying to figure out what exactly are the visible effects of your changes to #suspend and #suspendAndUnblock from May 30.<br>
<br>
There has been written so much about this on the list in the last months that it's hard to follow up. If you could just describe the changes very briefly, probably in one or a half sentence, that would be perfect. :D<br>
<br>
Thanks in advance,<br>
Christoph<br>
<br>
</span><span style="color:gray">---<br>
<i>Sent from <a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><span style="color:gray">Squeak Inbox Talk</span></a></i></span><span style="color:black"><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
<p><span style="color:black"> <o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>