[Vm-dev] Explicitly avoiding process switch

Igor Stasenko siguctua at gmail.com
Thu Aug 11 12:59:56 UTC 2011


On 11 August 2011 14:28, Henrik Johansen <henrik.s.johansen at veloxit.no> wrote:
>
>
> On Aug 11, 2011, at 2:11 37PM, Igor Stasenko wrote:
>
> On 11 August 2011 13:17, Nicolas Cellier
> <nicolas.cellier.aka.nice at gmail.com> wrote:
>
> I would properly comment the places where this "ATOMIC" operation is
>
> really used.
>
> Like in
> AtomicQueueItem>>makeCircular? :)
>
>
> I also remember discussion that some precautions in code to not insert
> suspension point(s) in ProcessorScheduler/Process/or Semaphore..
> but i forgot which one exactly.
> Is it LinkedList>>removeLink:?
>
> http://code.google.com/p/pharo/issues/detail?id=3498
> So suspension points in remove:ifAbsent (as written now)  and removeLink: are ok.
> Not in removeLink:ifAbsent: though.
> Used to be:
> link := self linkOf: aLinkOrObject ifAbsent: [^aBlock value].
> self removeLink: link.
> ^aLinkOrObject

i don't like this code, because it iterating list twice, first to find a link,
and second time to remove it.

I don't think it is a big secret that removing an element from linked
list could be done using single iteration :)

> Because, well, I didn't think you'd ever get in a situation where :
> 1) two processes would try to remove the same link
> 2)  first of them suspends after link assignment
> 3) second carries through, and actually removes link
> 4) first calls removeLink: , and default block raising error is triggered when link is not found.
> Cheers,
> Henry
>



-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list