Recipe for cooking 2.1.72's mm

Pavel Machek (pavel@Elf.mj.gts.cz)
Mon, 15 Dec 1997 11:58:30 +0100


Hi!

I'll present a way to make 72 completely unusable:

Take stress, run stress mega mega mega .... (many times). Then
enjoy. (I assume that number of mega must be bigger than your RAM+swap
ammount).

Machine is not dead, interrupt still works, magic unmount works, maybe
it is even some userland working - kswapd is active 'only' 99% of
time. (Debugging leds are _great_ think), hard disk does somesing very
short about once from two seconds or so. I can see led of user
processes flagshing _very_ shortly.

I tried to type killall stress at root console. Letters was not even
echoed in 5 minutes, so I considered machine pretty dead. Here's code,
there's nothing evil on it...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/fcntl.h>

int
main( int argc, char *argv[] )
{
unsigned long i;

for (i=0; i<argc; i++)
{
if (!strcmp( argv[i], "mega" ))
if (!fork())
{
char *p = malloc( 1024*1024 );
int j, start;
printf( "Process %d started at %d.\n", getpid(), start = time(NULL));
for( i=0; i<1024*1024; i++ ) p[i]=1;
for( j=1; j<100; j++ )
{
int a;
for( i=0; i<1024*1024; i++ ) a+=p[i];
}
printf( "Process %d done at %d (%d sec).\n", getpid(), time(NULL), time(NULL)-start);
}
}}

-- 
I'm really pavel@atrey.karlin.mff.cuni.cz. 	   Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).