<html 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=us-ascii">
<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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.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" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Eliot, all,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I'm baffled by this example:</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 resume explore</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I expected to get an error but the process just gets out of the semaphore and finishes happily.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#resume comment says:</p>
<p class="MsoNormal">                Primitive. Allow the process that the receiver represents to continue. Put
</p>
<p class="MsoNormal">                 the receiver in line to become the activeProcess.  *Fail if the receiver is
</p>
<p class="MsoNormal">                 already waiting in a queue (in a Semaphore or ProcessScheduler)*.  Fail if</p>
<p class="MsoNormal">                the receiver's suspendedContext is not a context.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The following works as expected - p sits at the semaphore:</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 explore</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This works as well (with the new VM) - p backs up and sits before the wait:</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 explore</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And this works too indeed - p sits at the semaphore again after suspend.</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 explore</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is this a bug? Or is the comment just outdated? </p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I've been trying to figure out possible ways how to prevent resuming a process being terminated (other than setting its suspendedContext to nil) and this unexpected behavior gave me a real hard time :)</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Many thanks for your help.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Best regards,</p>
<p class="MsoNormal">Jaromir</p>
</div>
</body>
</html>