• Aucun résultat trouvé

Designing the Partitioned Data Set

Four thi ngs are required for defin ition of a partitioned data set. First, a map for defi ning those areas on the d isk that are in use (allocated ) . For th is we create a track m ap that defines each track on the disk with one bit. If the bit is set to 1 , the corres­

pond ing track is free. I f the bit is set to 0, the track is in use. For a d isk with 77 tracks, a 1 0 byte track map is sufficient. The posi­

tion of each bit in the map defines the address of its associated track. The first bit in the map defi nes track 0, the second bit defines track 1 , etc. The track map is referenced whenever a data set is all ocated or scratched, so the smal lest d ata set possible woul d be 1 trac k in length .

Second, we need a sector map to keep track of wh ich sectors are in use and wh ich are free. As in the track map, we assign 1 bit in the map to each sector. If our d isk has 1 0 sectors per track, the sector map must be 770 bits in length, so we assign 97 bytes to it. As in the track map, the position of each bit defi nes the add ress of the associated sector. The sector map, table 1 , is used when a member is created in or deleted from a data set.

Third, a control block for defining the name and location of the partitioned data sets is needed . These blocks can immed iately fol low the maps, and should contain space for the d ata set name, starting track address of th e data set, length of d irectory in tracks, and the end ing track address of the data set.

Fol lowing this control block are simi lar

Member name

Start of data area address for member End of data area address for member Number of logical records i n use Data type of member

Unused

6 bytes 2 bytes 2 bytes 2 bytes 1 byte 3 bytes

Table 2: Format for the directory entry information.

control blocks for other d ata sets and unused (free) control blocks. A free control block is ind icated by the name field being fil led with binary Os.

The maps and the control b locks can all fit on a single track. This track is called the volume tab le of contents (VTOC) and begins with the volu me l abel, also known as the volume serial number (VSN). If we want a multitrack volume table of contents, we need to define how many tracks are in the table for use by the access method software.

A byte for a cou nt of the tracks in the volume itself shou ld be included. If our system is to handle d ifferent formats and densities it wou ld be wise to include the format information in the tab le of contents.

The access method software could then read the count of the number of tracks on the disk and the nu mber of sectors per track directly from the tab le and be able to hand le several formats without modification ..

In order to avoid wasting d isk space, 1 6 byte logical records can be blocked 8 to a 1 28 byte sector. A single track volume table of contents blocked in this way cou ld hand le 1 36 partitioned data sets. The fourth item required for a partitioned data set is a d i rec­

tory for the members in the d ata set. The d i rectory, table 2, begins at the first sector of the first track of the actual data storage area. The directory entries are 1 6 bytes long and packed 8 to a 1 28 byte sector. Each entry contains the name· of the member, the starting and end ing track and sector add resses of the member, the count of the number of sectors actual ly used by the member, and the data type of the mem ber. The data type may be :

0 Source d ata.

1 Core image object d ata.

2 Relocatable object data.

Both source and BAS IC programs may be stored in a member of data type 0, while data type 2 is used as input to a relocating loader, linking loader or linkage ed itor.

Data type 1 is used for storing nonrelocatab le programs.

Now that the design of the file structure is complete, we can design software that will create, manipu late and delete members and data sets.

Implementation

The first program we need is a d isk initial­

ization routine such as the one in figure 2.

The initial ization routine creates and em pties the volume table of contents track and clears the data storage area by setting it to 0.

The user is required to enter the volume serial number and the beginning and end ing track numbers of the d ata storage area. The track and sector maps are created so that the bits correspond ing to the data storage area are set to 1 (free space) and all other bits

W R I T E A Z E R O F l L L E D S E C T O R

Figure 2: Disk initializa­

tion program.

December 1978 © BYTE Publications Inc 1 69

Figure 3: The A LLOCA TE routine, used to put a new file onto the disk and update all pointers to indicate that the file is present.

1 70 December 1978 © BYTE Publications Inc

E R R O R E X I T

M E M B E R

S E A R C H D I R E CTORY FOR M E M B E R N A M E

S E ARCH SECTOR MAP FOR F R E E S P A C E

S E A R C H D I R E CTORY FOR E M P T Y E N T R Y

S E T S P A C E I N S E C T O R M A P

" I N U S E "

R E WR I T E VOL U M E T A B L E OF CONTENTS

B U I L D

DIRECTORY E N T R Y

OUTPUT R E A D C O M M A N D T E X T

L O O K S E A R C H O N L I N E D R I V E S FOR PROPER D I S K

S E A R C H TA B L E OF C O N T E N T S F O R DATA S E T N A M E

S E A R C H T R A C K M A P FOR SPACE

S E A R C H VOLUME TABLE O F C O N T E N T S FOR EMPTY CONTROL BLOCK

SET SPACE S T A T U S " I N U S E ' IN T R A C K M A P

S E T D I R E C TO R Y S E C T O R S ' I N U S E ' IN SE CTOR M A P

R E W R I T E VOLUME T A B L E OF C O N T E N T S

S E T D A T A STO R A G E A R E A T O Z E R O

are set to 0 (space used). The volume label, a cou nt of the trac ks used by the vol ume table of contents (permanently set to 1 ) and the maps are then written on the first sector of the first trac k of the disk. Al l other sectors of the table of contents track are set to bi nary 0. Every sector of the data storage area i s also set to 0. I ni tialization of the disk is now complete.

Once the d isk has been i n itial i zed, we can allocate data sets on it by using the al locate routine. Th e allocate routine shown in figu re

3 actual ly consists of two routines: one to allocate data sets, and one to allocate mem­

bers in a data set. To al locate a data set, the user enters the volume serial n umber of the d isk, the name of the data set to be al l ocated

(six characters maxi mum), the number of sectors to be used for d i rectory, and the n umber of tracks to be devoted to the data area. Note that the space used for the direc­

tory is included in the amount of space entered for the data area defi n ition.

The allocator rou tine then reads the volume tab le of contents track and verifies that the volume serial num ber on the d isk matches that entered by the operator and that the data set name to be used does not already exist. If neither test fails, the track map is scanned for contiguous free space equal to the amount requested by th e user.

If the free space is fou nd , th e necessary bits are reset to 0 in th e track map. The d ata set control block is now built by moving the req uired data into an em pty block i n the table of contents. The sector map is also updated to reflect the sectors used by the directory and the updated volume table of contents is rewritten on the d isk, com­

pleting the allocation of a data set.

To all ocate a member, the user m u st pro­

vide the volume serial number of the d isk as wel l as the name of the data set of which the mem ber will be a part, the mem ber's name (six characters maximum), m em ber data type, and the n u m ber of sectors to allo­

cate to the member. The al l ocator program agai n verifies that the proper disk is on line and that the data set exists. p btaining th e address of the partitioned data set's d i rec­

tory from the control bloc k for the data set, the al locator verifies that a member with the same name as that being al located does not al ready exist. If all is wel l , the sector map is scanned for contiguous free space i n the data set's data storage area sufficient to satisfy the user's request. If space is avai lable, an empty directory record is used to create a directory en try for the member. The sector map is then u pdated and the di rectory and table of contents are rewritten on the disk.

We now have a partitioned data set with

Circle 8 on inquiry card .

PUT A HANDLE