Xref: utzoo unix-pc.general:751 comp.sys.att:3375
Path: utzoo!utgpu!water!watmath!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!decwrl!hplabs!hp-sdd!ucsdhub!jack!elgar!ford
From: ford@elgar.UUCP (Ford Prefect )
Newsgroups: unix-pc.general,comp.sys.att
Subject: Re: How much memory is left? (Re: Swapping and wmgr)
Message-ID: <166@elgar.UUCP>
Date: 1 Jun 88 05:29:26 GMT
References: <449@bacchus> <153@elgar.UUCP> <459@bacchus> <371@icus.UUCP>
Reply-To: ford@elgar.UUCP (Ford Prefect )
Organization: Omnicron Data Systems,  Bonita, CA
Lines: 51

In article <371@icus.UUCP> lenny@icus.UUCP (Lenny Tropiano) writes:
>    if (!(proc.p_flag & SLOAD)) {
>	sprintf(buffer,"can't handle swapped process %d (flag=%05x)",
>		proc.p_pid, proc.p_flag);
>	werror(buffer,1);
>    }
>
>    upage = (long)ctob(proc.p_addr[0]);
>    read_mem((char *)&users, upage + U_OFFSET, (long) sizeof (struct user));

Try this:

	if (proc[procidx].p_flag & SLOAD)
	{
	    upage = (long)ctob(proc.p_addr[0]);
	    read_mem((char *)&users, upage + U_OFFSET,
		      (long) sizeof (struct user));
	}
	else
	{
	    upage = dbtob((long)proc.p_swaddr);
	    read_swap((char *)&users, upage + U_OFFSET,
		      (long) sizeof (struct user));
	}

where read_mem is to /dev/mem as read_swap is to /dev/swap.


>Here's a short program that will tell you how much memory you have...
>
>$ cc -c -O memory.c 
> ...

Here's an even shorter program that will tell you the same stuff;
fancy formatting or converting into bytes is left as an excersise for
the reader...

	echo 'maxmem/D
	physmem/
	freemem/' | adb /unix /dev/kmem


Of course you can't make mine setuid, but what do you want for
nothing, Rubber Biscuits?   :-) :-)


					-=] Ford [=-

"Once there were parking lots,		(In Real Life:  Mike Ditto)
now it's a peaceful oasis.		ford%kenobi@crash.CTS.COM
This was a Pizza Hut,			...!sdcsvax!crash!kenobi!ford
now it's all covered with daisies." -- Talking Heads