Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!munnari!otc!metro!osiris!greg From: greg@osiris.UUCP Newsgroups: comp.bugs.sys5 Subject: Re: Sys V handling of insufficient swap space. Message-ID: <306@osiris.oz> Date: Tue, 10-Mar-87 18:33:52 EST Article-I.D.: osiris.306 Posted: Tue Mar 10 18:33:52 1987 Date-Received: Thu, 12-Mar-87 18:45:37 EST References: <1035@wang7.UUCP> <1078@hoxna.UUCP> <444@vsedev.VSE.COM> <1083@hoxna.UUCP> Organization: Osiris Technology Pty Limited, Sydney, Australia Lines: 46 Keywords: swap crash Summary: Why it happens There seems to be a bit of confusion with regard to this. Firstly, to the best of my knowledge all System V.2 implementations will hang when they run out of swap space. A rough description of how this occurs follows.... The scheduler runs It looks around and possibly finds a process to run It then checks the amount of free memory and decides that it must swap a process out - calls swapout() swapout() picks a process to swap and starts copying it to swap but discovers that there is not enough swap space so it sleeps until more appears. Now if you're lucky the process picked to run may free up enough swap space to allow swapout() to continue and everythings fine until the next call to swapout(). However, if it doesn't free up enough space your system is now officially hung since the scheduler is asleep in swapout() and no longer doing its job. Which means that no more processes are scheduled and the whole system goes idle, regardless of how many runnable processes there are or how much physical memory is available. This is a major problem on any machine used for software development since any program which starts infinite recursion will eventually run out of swap space. For example the one line program main(){main();} will cause the system to hang. Allocating more swap space won't solve the problem a unless you have at least enough swap to hold the biggest possible program (say 2 Gigabytes for a machine with a reasonable sized virtual address space). Though this is probably feasable, I don't want to waste that much disc space just on the off chance that somebody might make a mistake. The only real solution is to change the kernel so that you are guaranteed to get more swap space and this can only really be done by killing processes. We have made the necessary mods to the kernel we sell with our hardware and it is virtually impossible to cause this problem on our machines. For various complex reasons you can't always kill a process, so our kernel can be made to hang but it requires deliberate programming effort and special circumstances. -- Greg Kable Osiris Technology Pty. Ltd. ACSnet: greg@osiris.oz Unit 4 UUCP: ...!seismo!munnari!osiris.oz!greg 372 Eastern Valley Way ARPA: greg%osiris.oz@seismo.arpa Chatswood, NSW 2067 VOICE: (02) 406 6299 Australia