lkml.org 
[lkml]   [1997]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: fork: out of memory
Date
From
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

\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.098 / U:1.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site