[Vm-dev] why does #resume affect waiting semaphore

Ben Coman btc at openinworld.com
Fri Feb 19 12:40:53 UTC 2016

Just a curiosity I've had for a while.  Intuituvely I would expect the
following produce { } since sem is never signalled.

   log := OrderedCollection new.
   sem := Semaphore new.
   p1 := [sem wait. log add: 1] forkAt: 41.
   p2 := [sem wait. log add: 2] forkAt: 41.
   p2 resume.
   log inspect.

but it produces {2}.

>From digging in the primitives I understand a bit why this happens.
What I'm interested in learning is, from an architecture perspective,
why is the existing behaviour preferred?

cheers -ben

More information about the Vm-dev mailing list