From owner-freebsd-questions Sun Jun 9 17:18:36 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id RAA18074 for questions-outgoing; Sun, 9 Jun 1996 17:18:36 -0700 (PDT) Received: from relay-2.mail.demon.net (disperse.demon.co.uk [158.152.1.77]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id RAA17991 for ; Sun, 9 Jun 1996 17:17:45 -0700 (PDT) Received: from post.demon.co.uk ([158.152.1.72]) by relay-2.mail.demon.net id ab19329; 10 Jun 96 1:17 +0100 Received: from jraynard.demon.co.uk ([158.152.42.77]) by relay-3.mail.demon.net id aa14209; 10 Jun 96 1:12 +0100 Received: (from fqueries@localhost) by jraynard.demon.co.uk (8.7.5/8.6.12) id VAA04908; Sun, 9 Jun 1996 21:25:11 GMT Date: Sun, 9 Jun 1996 21:25:11 GMT Message-Id: <199606092125.VAA04908@jraynard.demon.co.uk> From: James Raynard To: jmb@freefall.freebsd.org CC: jbarrm@panix.com, questions@freebsd.org In-reply-to: <199606091250.FAA03535@freefall.freebsd.org> (jmb@freefall.freebsd.org) Subject: Re: Design & Implementation of 4.4BSD Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >>>>> "Jonathan M. Bresler" writes: > > 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. It might also be worth mentioning that pseudo-code is very useful when writing code - first decide what the function is supposed to do, then write down pseudo-code that describes this in more detail, then write comments based on the pseudo-code. All you have to do then is fill in the gaps between the comments! 8-) > ps. this is one of the joys of FreeBSD--getting to see the real > code Absolutely! -- James Raynard, Edinburgh, Scotland | http://www.freebsd.org/~jraynard/ james@jraynard.demon.co.uk | jraynard@freebsd.org