Messages in this thread | | | Subject | Re: fork: out of memory | Date | Wed, 26 Nov 1997 13:39:24 +0100 (MET) | From | (Rogier Wolff) |
| |
Alan Cox wrote: > > > if (newfd >= files->cur_allocated) { > > if (newfd > files->cur_allocated) { > > /* Oops. Someone else must already be updating > > this, Not now baby.... I have a headache */ > > return -ENOMEM; > > } > > Ok race #1 for SMP. If you put the lock around it all then you still have to > worry about the SMP case of > > > if(blah->files[n]!=NULL && /* other CPU swaps here *. > blah->files[n]...)
If this is a "read" access to the array, then there is no problem: the new array should be identical (it's just been memcpy-ed).
If this is a write access, it should've gotten the write lock to the files strcture. Just like when you want to allocate a new fd.
The access to the pointer needs to be atomic. So if a pointer is larger than the bus width, and the other processor can insert a fetch between the low-word and the high-word access, then you're #$^%ed. But this violates one of the most basic paradigms of multiprocessor programming.
Roger.
-- ** R.E.Wolff@BitWizard.nl ** +31-15-2137555 ** http://www.BitWizard.nl/ ** Florida -- A 39 year old construction worker woke up this morning when a 109-car freight train drove over him. According to the police the man was drunk. The man himself claims he slipped while walking the dog. 080897
| |