Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!sharkey!cfctech!teemc!ka3ovk!drilex!axiom!linus!nixbur!nixpbe!nixsin!koerberm From: koerberm@nixsin.UUCP (Mathias Koerber) Newsgroups: comp.unix.questions Subject: atomic check and update of shm flag Message-ID: <1053@nixsin.UUCP> Date: 4 Jun 90 10:43:15 GMT Organization: Nixdorf Regional HQ Pte Ltd, Singapore Lines: 23 Can I safely assume, that a contruct like while (shm_addr->flag == 0) ; shm_addr->flag = getpid(); ensures that only one of several equal processes at a time have access to a resource? I fear that one process finds the flag set to zero, but is running out of time-slice, before it can set the flag, and then another process also finds the flag set to zero and uses the resource. If the above example doesn't work, what works? I'd like to have a solution with shm, since I don't want to add even another IPC-system (semaphores etc) only for this to work. Please e-mail, address as in my (.sig). Thx, Mathias -- Mathias Koerber |Tel: +65 / 7473828 ext 1852|Fax: +65 / 7474331 Nixdorf Computer Singapore|EUnet: koerber.sin@nixpbe |nerv: koerber.sin 2 Kallang Sector |uunet: uunet!linus!nixbur!koerber.sin Singapore 1334 |[Standard-disclaimer:All views personal... ]