I'm reviewing some code and feel suspicious of the technique being used.
In a linux environment, there are two processes that attach multiple shared memory segments. The first process periodically loads a new set of files to be shared, and writes the shared memory id (shmid) into a location in the "master" shared memory segment. The second process continually reads this "master" location and uses the shmid to attach the other shared segments.
On a multi-cpu host, it seems to me it might be implementation dependent as to what happens if one process tries to read the memory while it's being written by the other. But perhaps hardware-level bus locking prevents mangled bits on the wire? It wouldn't matter if the reading process got a very-soon-to-be-changed value, it would only matter if the read was corrupted to something that was neither the old value nor the new value. This is an edge case: only 32 bits are being written and read.
Googling for shmat stuff hasn't led me to anything that's definitive in this area.
I suspect strongly it's not safe or sane, and what I'd really like is some pointers to articles that describe the problems in detail.