"Wasted" Swap space

Duncan McEwan duncan at comp.vuw.ac.nz
Mon Feb 29 14:24:08 AEST 1988


Doing a "pstat -s" on our pyramid (90x, 8Mb memory) typically produces
something like the following

   20478k used (2534k text, 0k shm), 8402k free, 5306k wasted, 848k missing
   avail: 2*1024k 4*512k 8*256k 7*128k 10*64k 6*32k 13*16k 322*2k

I am curious about the rather high "wasted" figure.

I spent some time looking at the source to the 4.3bsd pstat and saw it was
calculating the figure as follows.

	waste = 0;
	db = ctod(pp->p_dsize), sb = up(db);
	waste += sb - db;
	db = ctod(pp->p_ssize), sb = up(db);
	waste += sb - db;

where the function "up" is

	up(size)
		register int size;
	{
		register int i, block;

		i = 0;
		block = dmmin;
		while (i < size) {
			i += block;
			if (block < dmmax)
				block *= 2;
		}
		return (i);
	}

I can certainly see what "up" is doing, but I dont understand *why* it is doing
it.

I presume "up" must in someway reflect the way 4.3bsd allocates swap space.  If
this is so, this method of allocation does not seem very optimal.  Could anyone
explain if this is the case, and if so, the justification for this allocation
strategy.

Also, does anyone know if this is what OSx does?  Is the space really wasted,
or is it a bug in "pstat"?

---

Duncan

Domain: duncan at comp.vuw.ac.nz			Path: ...!uunet!vuwcomp!duncan



More information about the Comp.sys.pyramid mailing list