15.1 The File ‘buf.h’

This file declares two structures called “buf” (4520) and “devtab” (4551). Instances of the structure “buf” are declared as ’bfreelist (4567) and as the array “buf” (!) (4535) with “NBUF” elements.

The structure “buf” is possibly misnamed because it is in fact a buffer header (or buffer control block). The buffer areas proper are allocated separately and declared (4720) as

   ``char buffers [NBUF] [514];''

Pointers from the “buf” array to the “buffers” array are set up by the procedure “binit”.

Other instances of the structure “buf” are declared as “swbuf” (4721) and “rrkbuf” (5387). No 514 character buffer areas are associated with “bfreelist” or “swbuf” or “rrkbuf”.

The “buf” structure may be divided into three parts:

(a) flags

These convey status information and are contained within a single word. Masks for setting these flags are defined as “B_WRITE”, “B_READ” etc. in lines 4572 to 4586.

(b) list pointer

Forward and backward pointers for two doubly linked lists, which we shall refer to as the “b”-list and the “av”-list.

(c) i/o parameters

A set of values associated with the actual data transfer.