Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jun 1996 05:50:52 -0700 (PDT)
From:      "Jonathan M. Bresler" <jmb>
To:        jbarrm@panix.com (Barry Masterson)
Cc:        questions@freebsd.org
Subject:   Re: Design & Implementation of 4.4BSD
Message-ID:  <199606091250.FAA03535@freefall.freebsd.org>
In-Reply-To: <Pine.BSF.3.91.960609083447.2892A-100000@jbarrm.dialup.access.net> from "Barry Masterson" at Jun 9, 96 08:36:19 am

next in thread | previous in thread | raw e-mail | index | archive | help
Barry Masterson wrote:
> 
> Hi,
> 
> I'm working my way thru the recently released book entitled
> "The Design and Implementation of the 4.4BSD Operating System",
> and have come across some algorithm code samples on pages 199 & 203:
> 
> disksort(dq, bp)
>     drive queue *dq;
>     buffer *bp;
> {
>     if (drive queue is empty) {
>         place the buffer at the front of the drive queue;
>         return;
>     }
>     if (request lies before the first active request) {
>         locate the beginning of the second request list;
>         sort bp into the second request list;
>     } else
>         sort bp into the current request list;
> }
> 
> I'm familiar with the basics of c/c++, perl, shell scripts, but this
> use of "the", "of", "into", "at" is something I've yet to see. It
> seems a little too human readable to be real code.
> 
> What language is this?  Are there other examples of this type of
> programming in the FreeBSD source code?

	its called "psuedo-code".  rather then present the actual source
	the authors are presenting the algorithm stripped of the details
	of data structures and pointer (etc....) that obscure the purpose
	of the code.  rather liek the difference between the blueprints
	and the building itself.

	the purpose of the code is to sort disk accesses by the position of
	the data on disk so that the heads walk the disk from edge to edge
	doing every I/O possible on each pass.  without this the heads 
	would shuttle from cylinder to cylinder in a rather random pattern.
	seeks are the longest component of disk access time.  the code
	minimizes seeks.

	the real code for ufs is in: /sys/ufs/ufs/ufs_disksubr.c:disksort()

	the comments matche the pseudo-code well.  take a look :)

jmb

ps.	this is one of the joys of FreeBSD--getting to see the real
	code
--
Jonathan M. Bresler           FreeBSD Postmaster             jmb@FreeBSD.ORG
FreeBSD--4.4BSD Unix for PC clones, source included. http://www.freebsd.org/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606091250.FAA03535>