29.12.2012 Views

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

travels the turnpike. In this manner, all sec<strong>to</strong>rs of a cylinder are accessed before the<br />

disk drive has <strong>to</strong> step <strong>to</strong> the next cylinder.<br />

It is not always possible <strong>to</strong> allocate space consecutively. For instance, say we want <strong>to</strong><br />

add a granule <strong>to</strong> an existing file but the next granule consecutive <strong>to</strong> the last granule of<br />

the file has already been allocated <strong>to</strong> another file. Our file must then be fractured in<strong>to</strong><br />

more than one piece. We term each piece of the file an EXTENT. <strong>The</strong> system's file access<br />

routines logically connect each EXTENT so <strong>to</strong> a program accessing the file, it appears as<br />

if the file exists as one continuous allocation of space.<br />

<strong>The</strong> disk direc<strong>to</strong>ry s<strong>to</strong>res all the allocation data on each file contained on the disk.<br />

Allocation data on a particular file is s<strong>to</strong>red in a direc<strong>to</strong>ry entry record. Each record<br />

can hold the allocation information on up <strong>to</strong> four extents. <strong>The</strong> first record is termed the<br />

File's Primary Direc<strong>to</strong>ry Entry or FPDE while all succeeding direc<strong>to</strong>ry records are<br />

considered <strong>to</strong> be the File's Extended Direc<strong>to</strong>ry Entries or FXDE records. In order <strong>to</strong><br />

access the file data, the system's file access routines must utilize the information<br />

contained in the file's FPDE.<br />

It is impractical <strong>to</strong> have <strong>to</strong> read the FPDE each time another sec<strong>to</strong>r of data is<br />

transferred. <strong>The</strong>refore, the scheme employed is <strong>to</strong> access the direc<strong>to</strong>ry once in a process<br />

<strong>to</strong> obtain all of the file's access information and place the information in<strong>to</strong> a memory<br />

area termed a File Control Block (FCB). <strong>The</strong> actual process is termed "opening the file".<br />

<strong>The</strong> reverse process, that of updating the direc<strong>to</strong>ry entry once the access of a file is<br />

complete is termed "closing the file". <strong>The</strong> DOS provides SuperVisor Call requests <strong>to</strong><br />

perform the OPEN and CLOSE functions. <strong>The</strong>se type of requests are called "file control"<br />

functions since they give you the means of controlling the disk file. Other types of<br />

requests are associated with accessing the data in a file and are thus called "file<br />

access" requests. INTERFACING VIA SUPERVISOR CALLS, chapter 7, describes each access and<br />

control SuperVisor Call.<br />

Data is generally collected in<strong>to</strong> units called RECORDS. <strong>The</strong>se may be fixed-length records<br />

with each record being exactly the same length or they may be variable length records<br />

where the length of the record varies from record <strong>to</strong> record. Fixed-length records can be<br />

accessed sequentially (i.e. starting from record zero and continuing <strong>to</strong> the last record<br />

of the file). This type of access is termed RECORD I/O. <strong>The</strong> DOS supports fixed length<br />

records from one <strong>to</strong> 255 characters in length by au<strong>to</strong>matically handling the blocking and<br />

deblocking of records in<strong>to</strong> and out of the disk file I/O buffer. Since the DOS<br />

standardizes disk file I/O buffer sizes at 256 characters each, record lengths of 256 are<br />

handled directly without recourse <strong>to</strong> the blocking and deblocking used on shorter records<br />

and these records can also be transferred <strong>to</strong> and from the disk more quickly. Record sizes<br />

larger than 256 can be used in an application program; however, the blocking and<br />

deblocking of records must be performed entirely within the application while, in<br />

general, the application will use 256-character records <strong>to</strong> and from the system.<br />

Henceforth, any reference <strong>to</strong> the term RECORD will consider <strong>to</strong> be associated with a record<br />

which ranges from 1 <strong>to</strong> 256 characters in length.<br />

Fixed length records can also be accessed directly by record number (which is cus<strong>to</strong>marily<br />

called RANDOM ACCESS). <strong>The</strong> DOS provides SuperVisor Call requests <strong>to</strong> position the record<br />

pointer maintained in the File Control Block <strong>to</strong> the record of choice. <strong>The</strong> application can<br />

then address the record via READ or WRITE SuperVisor Call access requests. Additional<br />

SVCs provide other functions associated with the access of a file.<br />

<strong>The</strong> structure of variable length records is highly dependent on the programming language<br />

used <strong>to</strong> code the program. Most high-level languages (BASIC, FORTRAN, etc) provide<br />

variable length file structures which may not be equivalent across each language. One<br />

common structure which is supported by more than one language is <strong>to</strong> use a character or<br />

character combination <strong>to</strong> represent the end of the record. <strong>The</strong> BASIC language operating<br />

under <strong>Version</strong> 6 uses the ASCII code X'0D' which is a CARRIAGE RETURN <strong>to</strong> indicate the end<br />

6-2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!