Just for the sake of discussion, you try to prevent interruptions by using
assignments, right ? But you still need #== which seems like a (potential)
message send, which brings us back to the other arguments in this thread.
Furthermore, the dummy value must be different for each of the
On 04 Apr 2014, at 19:29, Igor Stasenko siguc...@gmail.com wrote:
On 4 April 2014 18:31, Sven Van Caekenberghe s...@stfx.eu wrote:
Just for the sake of discussion, you try to prevent interruptions by using
assignments, right ? But you still need #== which seems like a (potential)
message
On 4 April 2014 22:54, Sven Van Caekenberghe s...@stfx.eu wrote:
On 04 Apr 2014, at 19:29, Igor Stasenko siguc...@gmail.com wrote:
On 4 April 2014 18:31, Sven Van Caekenberghe s...@stfx.eu wrote:
Just for the sake of discussion, you try to prevent interruptions by
using assignments, right
On Thu, 3 Apr 2014, Igor Stasenko wrote:
On 3 April 2014 00:11, Sven Van Caekenberghe s...@stfx.eu wrote:
Hi,
Is it possible to have a simple lock-free atomic counter in Pharo 3.0 ?
nextId
^ idCounter := idCounter + 1
Or is it still possible that two
I hate to bust this old evilness out, but is it feasible to abuse
#become: for this purpose? I haven't used it in so long I don't
actually remember whether that's feasible semantics with ivars.
On Thu, Apr 3, 2014, at 09:08 AM, Levente Uzonyi wrote:
On Thu, 3 Apr 2014, Igor Stasenko wrote:
Hi,
Is it possible to have a simple lock-free atomic counter in Pharo 3.0 ?
nextId
^ idCounter := idCounter + 1
Or is it still possible that two process entering this code can mess things up ?
I vaguely remember a discussion about that long ago...
TIA,
Sven
On 3 April 2014 00:11, Sven Van Caekenberghe s...@stfx.eu wrote:
Hi,
Is it possible to have a simple lock-free atomic counter in Pharo 3.0 ?
nextId
^ idCounter := idCounter + 1
Or is it still possible that two process entering this code can mess
things up ?
#+ is a message send. So
so, lock-free counter can be something like:
atomicIncr
| oldValue |
[
oldValue := self atomicSwapCounterWithDummy.
oldValue == dummy ] whileTrue: [ Processor yield ].
^ counter := oldValue + 1
atomicSwapCounterWithDummy
| old |
old := counter.
counter := dummy.
^ old
so you use dummy to
extra note about yielding:
- if i remember correctly, it yields on same priority level, letting other
process (if any)
at same priority level to take control.
and if there's none, then it is NOP.
so, if counter incr. used by processes with different priority it is better
to replace it with 1 ms