swap space

Tom Tkacik CS/50 tkacik at hobbes.cs.gmr.com
Fri Jun 14 01:26:29 AEST 1991


In article <1991Jun13.122803.25362 at ims.alaska.edu>, floyd at ims.alaska.edu
(Floyd Davidson) writes:
|> In article <1991Jun13.065207.10089 at ucunix.san.uc.edu>
adams at ucunix.san.uc.edu (J. Adams - SunOS Wizard) writes:
|> >In article <1991Jun11.030216.6155 at ceilidh.beartrack.com>
dnichols at ceilidh.beartrack.com (DoN Nichols) writes:

|> >  In fact, a new process will not be
|> >allowed to run if it cannot fit in the virtual space available.  It will
|> >be killed in the memory allocation stage.  If you examine the kernal .o
|> >files, you will see that the only swapping program is vmswap.c.  This
|> >program manages/shares the same virtual address space as vmpage.c.
|> 
|> I don't know one way or the other on this.  Does it kill the new
|> process or kill an old process?  I know if existing processes
|> ask for more memory and swap space is full it will start killing off
|> processes.  But I don't know what the algorithm is.

When a process asks for more memory than there is virtual memory,
(via malloc, or sbrk(2)), an error will be returned, and the process will not
get any bigger.  It will not be killed by the kernel either, it will usually
call exit by itself, or fail with a segmentation violation as it mindlessly
tries to use the NULL pointer returned by malloc.
(Of course, a proper program will try to clean up after itself and handle the
lack of memory in a graceful fashion.:-)

I believe that if there is still plenty of virtual memory but
very little swap space left, if a program then calls malloc (or sbrk)
the same error will be returned, and the program will not grow.  I do not think
that a running program will be killed because there is not enough memory to
grow into, it simply will not be allowed to grow anymore.

If a new process tries to start running, and there is no more memory,
the kernel will not let it run.  I do not think that it will start and then
be killed by the kernel.  The kernel should never just start killing
off processes when swap space runs out.  Individual processes will start to
die off as they need more memory and cannot get it.

--
Tom Tkacik
GM Research Labs
tkacik at hobbes.cs.gmr.com
tkacik at kyzyl.mi.org



More information about the Comp.sys.3b1 mailing list