This chapter helps you understand concepts about storing data files on mass storage devices such as disks and tapes. It will help you learn how to make better use of your mass storage devices.
As the term mass suggests, mass storage devices are designed to store large quantities of data. Just how much data constitutes a large amount depends on the device itself. Common mass storage devices include the following:
The most common devices are the hard and flexible disk drives. As a storage medium, disks can store several thousand to tens of millions of bytes of data. To keep this large amount of data well organized and accessible, mass storage is organized into volumes and files.
A data file can be compared to a chapter in a book. Just as a book chapter contains many sentences, a data file contains lines of a BASIC program or other information stored in data bytes. Just as a chapter name identifies a chapter, a file name identifies a data file.
A volume is merely a collection of files, just as a book is a collection of chapters.
Contents of a book are listed in the table of contents. Contents of a volume are listed in a directory.
While it is easiest to use the default volume, there are times when you will want to use another mass storage device. In such cases, you will need to know how to specify the other volume using a volume specifier. If you read the "Verifying and Labeling Peripherals" chapter in Installing and Maintaining HP BASIC/WS 6.2 or followed the instructions during installation, you should already have the volume specifier of each of your mass storage devices written on a label that you placed on the device's front panel.
Syntax of a Volume Specifier
Examples
:CS80,700
:,700
:HP9122,702,1
:,702,1
:SCSI,1400,1
:,1400,1
In each case the device type ("CS80", "HP9122", or "SCSI") can be left out. If it is, BASIC will determine the device type automatically. Thus, the "shortened" version works in each of the above examples.
The following table describes each part of the volume specifier:
Component | Explanation
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Device type | Identifies the mass storage device's type. Once BASIC determines the
device type, it can also determine device capacity, and other information
required to determine the access method for the device.
Here are some examples:
For a list of all device types, see the HP BASIC 6.2 Language Reference entry for MASS STORAGE IS. |
||||||||
Device selector | Identifies the interface's select code (4, and 7 through 31) and primary
address (HP-IB and SCSI devices only). Here are examples:
|
||||||||
Unit number | Tells BASIC additional information about the device's unit-number setting. Many devices have hard-wired unit numbers, while others use the unit number to identify different portions of one disk. For instance, the unit number of the right drive of an HP 9122 is 1, the left drive is 0 (internal drives of Model 236 computers are numbered in the opposite order). | ||||||||
Volume number | Identifies the volume number (multi-volume hard disks only, such as HP 9133X drives). |
A typical configuration is shown below, representing:
The volume specifiers for the HP 9122 Disk Drive are:
:,700,0 and :,700,1 | The drive type is "CS80", but is omitted. The HP-IB interface select code is "7". The primary address of the drive is "00". The left drive unit number is "0", and the right drive unit number is "1". |
The volume specifier for the HP 9133 Disk Drive flexible disk drive unit is:
:,705,0 | HP-IB interface select code is "7". Primary address of the drive is "05". The drive unit number is "0". |
The volume specifiers for the HP 9133 Disk Drive hard disk are:
:,706,0,0 and :,706,0,1 | HP-IB interface select code is "7". Primary address of the drive is "06". The hard disk drive unit number is "0". The first volume number is "0". The second volume number is "1". |
To determine whether or not a disk is formatted, check to see if there is a directory on the disk. To do this, use CAT (you may need to specify the volume specifier if you loaded BASIC from a flexible disk):
CAT [Return] Catalogs the default drive
CAT ":,700" [Return] Catalogs the volume :,700
There are two classes of results for a CAT:
Volume | The Disk Is Formatted | The Disk Is Not Formatted |
---|---|---|
LIF | :CS80,700,1
LABEL: B9826 |
Error 85 Media uninitialized |
HFS | :CS80,700,1
LABEL: B9826 FORMAT: HFS |
Error 84 Record not Found |
If you are not sure which format you should use, see the section, "Choosing a Directory Format," later in this chapter.
A directory contains information about files, such as file name, size, and type. A directory is itself a file, but it is used only to organize and control access to other files. This section describes the two BASIC directory formats that implement hierarchical directories:
As the word hierarchy suggests, hierarchical directories are arranged in levels. Such a directory may contain either files or other directories.
In the following figure, the directory named KATHY is subordinate to the directory named Project_one because Project_one contains the information describing KATHY. The directory named PROJECTS is at level 1, the root directory. You cannot create a directory at a higher level than the root level.
Hierarchy of Directories
Suppose you're managing several projects, each of which needs to access a shared disk. To organize the files for each project separately, you can create a directory for each project (as shown in the previous figure). Within each project directory, you can have a directory for each person working on the project, and so on.
Because files at different locations in the directory structure can have the same file name, you can use generic file names to identify similar project functions in the different projects. For example, the file budget in the Project_one directory is distinct from the file budget in the Project_two directory.
To maintain security, BASIC provides the capability of protecting access to directories and files. For example, you may wish to allow only members of a project team to read that project's files. Or, you may wish to prevent other users from altering the contents of a personal file. See "Protecting Files" in the "Using Directories and Files" chapter in this manual.
To access a directory or file, you must specify its location in the hierarchical directory structure. This location is specified by a list of directories, called a directory path, that you must follow to reach the desired file or directory. Directory names in the list are delimited by a slash ( / ).
For example, in the directory structure illustrated previously, the file specifier:
"/PROJECTS/Project_one/JOHN/f1"
defines the directory path to the file f1 through its superior directories. The directory path to a file begins at one of these locations:
The current working directory is the directory specified by the most recent MASS STORAGE IS statement. The HP BASIC 6.2 Language Reference discusses the rules for specifying SRM and HFS files and directories.
On the Series 200/300 BASIC system, there are three directory formats available for disks (and other mass storage media):
The following recommendation will help you choose a format:
Feature | HFS | LIF | For More Information |
---|---|---|---|
Directory structure | Hierarchical (multi-directory) structure. | Single directory on each volume. | See preceding examples, and the Using Directories and Files chapter. |
Multiple systems on same volume | HP-UX, BASIC, and Pascal systems can share a disk. | BASIC and Pascal can share a disk. | See Installing and Maintaining HP BASIC/WS 6.2 |
File compatibility | Text files are the interchange method. | ASCII files are the interchange method. | See the Porting and Sharing Files chapter of HP BASIC 6.2 Porting and Globalization. |
Extensible files | Files are extensible (when a file would otherwise overflow, the system automatically adds space to it). | File length is fixed. | See Data Storage and Retrieval chapter of HP BASIC 6.2 Programming Guide. |
Access times | Generally slower than LIF. | Generally faster than HFS. | For more exact data, you can use the benchmarking methods shown in the Efficient Use of the Computer's Resources chapter of HP BASIC 6.2 Advanced Programming Techniques. |
TRANSFER | Not really implemented as a background process. | True background process and high data rates. | See the Transfers and Buffered I/O chapter of HP BASIC 6.2 Programming Guide. |
Overhead required | Requires slightly more overhead than LIF. | Requires slightly less overhead than HFS. | (Information follows.) |
HFS disks require a certain amount of overhead. Overhead is the space on the disk required to store just the directory format and not any data files.
Disk Size | Approximate Overhead |
---|---|
Single-sided 3 1/2-inch, and 5 1/4-inch flexible disks | 44% (256-byte sectors) |
Double-sided 3 1/2-inch flexible disks | 22% (256-byte sectors) 18% (1024-byte sectors) |
55-Megabyte hard disk | 6% |
130-Megabyte hard disk | 6% |
NOTE |
---|
You should keep the disk less than 90% full for optimum performance. |
Data on mass storage devices is physically organized in tracks and sectors. A track is a specific band circling the disk like lanes on a race track. A sector is a set of contiguous bytes (eight bits, or binary units) on a single track. A sector is the smallest unit of data that can be written and read. To change one byte on a disk, you must read the entire sector, change the byte, and then write the entire sector to the appropriate location.
Generally you need not worry about disk organization. However, there are two topics that you should be familiar with: disk interleave and initialization. Let's look at each of these topics in turn.
Interleaving a disk numbers the sectors according to a specific interval. An interleave factor of 1 numbers sectors consecutively. A factor of 2 causes the system to skip every other sector. BASIC numbers each sector on the disk using the same interleave factor on all tracks; that is, each file cannot have a separate interleave factor. The following figure compares these two interleave factors.
Examples of Disk Interleave
The purpose of disk interleave is to increase data-transfer rates. If we are reading data from a spinning disk, and the data have formats that differ from the computer's internal data formats, the computer must change the data's format to the computer's internal format after each item is read. During this time, the disk is still spinning.
If processing the items in a sector takes more time than it takes for the next sector to pass under the read/write head, then the system must wait one full revolution of the disk until the next sector passes under the head again. By interleaving a disk, you can provide time for this processing, and reduce the time the system must wait for the next sector to pass under the read/write head.
You can choose the interleave factor when you initialize a disk using INITIALIZE. See the installation section of Installing and Maintaining HP BASIC/WS 6.2.
When a blank disk is shipped from the factory, there are no files on it, nor even an empty directory. You will need to put a directory on the disk before using it. Some computer systems and documentation call this formatting a disk. Use the INITIALIZE statement to format disks.
NOTE |
---|
Since initializing wipes out everything on a disk, any data files on that disk will be lost. Always do a CAT of the disk before you initialize it. |
Here is what initialization does to a disk:
The following statement initializes a flexible disk in drive unit 0 at address 700:
INITIALIZE ":,700,0" [Return]
Note that this statement initializes the disk using the default parameters for interleave factor and so forth. Refer to the HP BASIC 6.2 Language Reference for further information about INITIALIZE.
SCSI disk drives are configured and used in a manner very similar to HP-IB disk drives. However, there some important details about SCSI that deserve special attention.
To use a SCSI disk, you must have one of the following interfaces:
All SCSI interfaces are identified by a select code. Select codes are set to default values at the factory, but they may be changed. You should not install two or more interfaces with the same select code.
Interface | Factory Default\Select Code |
---|---|
Model 340 Built-in SCSI Interface | 28 |
Model 345, 362, 375, 382 Built-in SCSI Interface | 14 |
HP 98658A SCSI Interface | 14 |
Note that both SCSI interfaces and SCSI disks have user-settable addresses. These addresses are set to defaults at the factory and do not need to be changed in most cases. You should never set the SCSI interface address to the same value as the SCSI disk. In particular, avoid setting a SCSI disk address to 7, since this address is the factory default address for SCSI interfaces.
You must have an HP Series 300 computer with Boot ROM revision C or later to boot HP BASIC from a SCSI disk. The boot ROM revision appears on the screen when you turn on the power to your computer. You cannot boot from a SCSI disk using an HP Series 200 computer. Even though you cannot boot from a SCSI disk in some situations, you can access SCSI disks from any Series 200/300 computer with a SCSI interface.
The Mass Storage Volume Specifier (MSVS) for a disk drive identifies the drive using a numeric code. The numeric code represents the select code of the interface connected to the drive and the drive address.
The MSVS for a SCSI drive has this general form:
:SCSI,ssaa
where:
ss = A one or two digit number that is the SCSI interface select code.
aa = A two digit number (leading zero if required) that is the SCSI drive address.
Here are some examples of MSVSs for SCSI disk drives:
:SCSI,1400 A SCSI-type disk on select code 14, address 00.
:,1405 A disk on select code 14, address 05.
As the second example illustrates, it is not necessary to explicitly identify the drive type; BASIC will determine the type automatically.