On 2021-12-30T20:08:48+01:00, christoph.thiede@student.hpi.uni-potsdam.de wrote:<br>
<br>
> Hi all,<br>
> <br>
> the docs on suspendedContext in the Process class comment say:<br>
> <br>
>     if nil, then I am either the active process or I have been terminated.  If not nil it is the Context at the hot end of my stack<br>
> <br>
> To me, this would indicate the following invariant:<br>
> <br>
>     self assert: Processor activeProcess suspendedContext isNil.<br>
> <br>
> However, this invariant is violated if you simulate this expression rather executing it:<br>
> <br>
>     (Process<br>
>         forBlock: [self assert: Processor activeProcess suspendedContext isNil]<br>
>         runUntil: [:ctx | ctx isDead or: [ctx selector = #defaultAction]])<br>
>             resume.<br>
> <br>
> Do you think this is a bug and should be fixed? We could do this by patching all assignors to suspendedContext in the 'changing suspended state' protocol on Process, maybe even as a small pattern like this:<br>
> <br>
>     step<br>
> <br>
>         ^ self doStep: [:ctx | ctx step]<br>
> <br>
>     stepToCallee<br>
>         "Step until top context changes"<br>
> <br>
>         ^ self doStep: [:ctx | | ctxt |<br>
>             ctxt := ctx.<br>
>             [ctxt == ctx] whileTrue: [ctxt := ctxt step].<br>
>             ctxt]<br>
> <br>
>     doStep: aBlock<br>
>     <br>
>         | ctxt |<br>
>         ctxt := suspendedContext.<br>
>         suspendedContext := nil.<br>
>         ^ suspendedContext := Processor activeProcess<br>
>             evaluate: [aBlock value: ctxt]<br>
>             onBehalfOf: self<br>
> <br>
> Where #doStep: would handle the effective process and read, set to nil, and set again the suspendedContext of the receiver. Disclaimer: The above is pseudocode only so far.<br>
> <br>
> Or isn't this worth the overhead and the invariant above has only to be valid for processes that are executed by the VM? :-)<br>
> <br>
> Best,<br>
> Christoph<br>
> <br>
> ---<br>
> Sent from Squeak Inbox Talk<br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211230/03409854/attachment.html><br>
<br>
Addendum: In some situations, the suspendedContext during simulation might even be out of date, for instance, inside a #stepToSendOrReturn.