atomicOp problem

BCS anon at anon.com
Thu Oct 21 07:03:54 PDT 2010


Benjamin Thaut <code at benjamin-thaut.de> wrote:
> I recently read the book "the D programming language" and wanted to try 
> out a few of the multithreaded examples pointed out in this book. I 
> tried to write a version of the bank account example using the atomicOp 
> from core.atomic. But when I compile it, it never finishes, it just gets 
> stuck in a endless loop inside atomic.d I think.
[...]
> If you could please point out what I did wrong I would be very glad. If 
> I did not do anything wrong, I don't quite understand whats the exact 
> problem because the code inside atomic.d looks good (at least at my 
> level of understanding)

Are you sure it's endless? IIRC atomic increment on x86 has some fairly severe performance considerations and you are setting it ip for maximal contention.

Try running it for 100 cycles and see if that works.

OTOH I'm no expert so I could be totally off base.

> -- 
> Kind Regards
> Benjamin Thaut




More information about the Digitalmars-d-learn mailing list