Hi Ben,

Firstly be careful because atomic usually means that the thread cannot be
interrupted by a concurrent native thread, so an atomic operation has to be
guaranteed at processor level.

Assuming that by atomic you mean that the operation's process cannot be
preempted by another green thread, yes there is big problems with non local
returns.

Two main issues:
- NLR can trigger unwind blocks, which can switch to another process.
- NLR can fail, triggering the cannotReturn: call-back, which can switch to
another process.





*I understand generally that an inlined  #ifTrue  is atomic.  Forexample,
here after the primitive returns, no interruption can occurbefore the
#ensure is invoked...    self primitiveWaitAcquire ifTrue:
 [mutuallyExclusiveBlock ensure: [self release]].*

The exact answer is that #*ifTrue*: can be interrupted if *self
primitiveWaitAcquire *is not a boolean, and can't be interrupted if it's a
boolean. It's nice to mark in a comment if part of the method's code has
not to be interrupted to avoid issues years later.




*But I want to know whether a non-local return could have an impact onthat
atomicity. For example ...    self primitiveWaitAcquire ifTrue:           [
^ mutuallyExclusiveBlock ensure: [self release]]*

In your code there is no non local return because ifTrue: is inlined by the
Bytecode compiler. Try to compile it and look at the bytecode you will see.

Else as I said at the beginning of the mail, a non local return can imply a
process switch if that was your question.







On Mon, Jun 6, 2016 at 2:46 PM, Ben Coman <[email protected]> wrote:

> I understand generally that an inlined  #ifTrue  is atomic.  For
> example, here after the primitive returns, no interruption can occur
> before the #ensure is invoked...
>     self primitiveWaitAcquire ifTrue:
>            [mutuallyExclusiveBlock ensure: [self release]].
>
> But I want to know whether a non-local return could have an impact on
> that atomicity. For example ...
>     self primitiveWaitAcquire ifTrue:
>            [ ^ mutuallyExclusiveBlock ensure: [self release]]
>
> cheers -ben
>
>

Reply via email to