How much memory is left? (Re: Swapping and wmgr)

Ford Prefect ford at elgar.UUCP
Wed Jun 1 15:29:26 AEST 1988


In article <371 at icus.UUCP> lenny at 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 at crash.CTS.COM
This was a Pizza Hut,			...!sdcsvax!crash!kenobi!ford
now it's all covered with daisies." -- Talking Heads



More information about the Unix-pc.general mailing list