I have a case where threads try to add to a common area (in shared memory).
If the datum is already present they should append to it, rather than
create a new instance. When several threads simultaneously have the same (new) datum,
all their checks to see if it is already present say it is missing and
so they all try to add it:-(
At present I am getting round this by forcing all updates via thread zero.
I am not sure my code is working and it seems an ugly hack.
Is there a better way?
Has anyone got a working example?
As always any help would be most welcome.