[Vm-dev] Unexpected #resume behavior
Jaromir Matas
mail at jaromir.net
Thu Jan 13 18:28:59 UTC 2022
Hi Eliot, all,
I'm baffled by this example:
p := [Semaphore new wait] fork.
Processor yield.
p resume explore
I expected to get an error but the process just gets out of the semaphore and finishes happily.
#resume comment says:
Primitive. Allow the process that the receiver represents to continue. Put
the receiver in line to become the activeProcess. *Fail if the receiver is
already waiting in a queue (in a Semaphore or ProcessScheduler)*. Fail if
the receiver's suspendedContext is not a context.
The following works as expected - p sits at the semaphore:
p := [Semaphore new wait] fork.
Processor yield.
p explore
This works as well (with the new VM) - p backs up and sits before the wait:
p := [Semaphore new wait] fork.
Processor yield.
p suspend.
p explore
And this works too indeed - p sits at the semaphore again after suspend.
p := [Semaphore new wait] fork.
Processor yield.
p suspend.
p resume explore
Is this a bug? Or is the comment just outdated?
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 :)
Many thanks for your help.
Best regards,
Jaromir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20220113/efb1ce3b/attachment.html>
More information about the Vm-dev
mailing list