File control block

from Wikipedia, the free encyclopedia

A file control block is a temporary data structure used to manage open files in certain operating systems .

Details

The operating system stores and manages in an FCB all information it needs about a specific open file for its use. Since the FCB is normally in the memory of the application program and not in the operating system's own memory, a program can keep as many files open at the same time as it wants, provided it reserves enough memory space for the FCBs required for this. The main advantage of FCBs lies in this flexible use of memory - a program that requires fewer files has to use less space for FCBs and can instead use the memory for other purposes. A major disadvantage of this, however, is that the application program has to know the size of the FCB, since it has to provide the necessary memory itself; therefore, this size cannot be increased in later operating system versions - for example to include additional information required internally by the operating system - without the compatibility with older application programs being destroyed.

CP / M only uses FCBs for file addressing. MS-DOS uses a different file system ( FAT ), but in versions 1.x it still uses the traditional FCBs for file access, also to allow third-party providers of CP / M-based software to port their programs quickly and easily.

MS-DOS versions from 2.0 and newer MS-DOS-compatible operating systems encountered the size problem described above, as there was no space in the FCB to store information that was necessary for using the newly introduced subdirectories . They only make FCBs available for reasons of compatibility, and they use file handles as the standard method for file access, with the actual management data for a file now being managed internally in an operating system memory area reserved for this purpose.

In these operating systems, the FCBs are only dummies that contain a reference to the actual file information managed in the operating system's own memory. The number of such dummies is limited, usually 4; to increase it, the FCBS = parameter can be specified in the CONFIG.SYS file at boot time , although a certain amount of memory is permanently reserved for each possible FCB dummy, which cannot be used otherwise. This parameter even still exists in Windows 2000 or Windows XP (32-bit version only), but is only important when using certain DOS programs such as WordStar .

Structure of an FCB with CP / M

An FCB consists of a sequence of 33 or 36 bytes with drive, file name and other information.

byte 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14th 15th 16..31 32 33 34 35
element DR F1 F2 F3 F4 F5 F6 F7 F8 T1 T2 T3 EX S1 S2 RC D0..D15 CR R0 R1 R2
byte value description
DR 0..16 Drive ( DR ive)
  0 Standard drive
  1 Drive A:
  ... ...
  16 Drive P:
F1..F8 A..Z File name ( F ile) in capital letters
T1..T3 A..Z File extension ( T ype) in capital letters. Bit 7 has a special meaning
T1.7 1 Read-only file
T2.7 1 System file
EX 0..31 Number of the current EX tents.
S1 0..255 reserved for internal use ( S ystem 1 )
S2 0..255 reserved for internal use ( S ystem 2 )
RC 0..127 Number of records ( R ecord C ount) of the current extent
D0..D15 0..255 System area for internal use
CR 0..255 Current ( C urrent) R ECORD for sequential file access.
R0..R1 0..65535 Current R ecord for direct file access.
R2 0..1 Reserved for direct file access.

CP / M provides a standard FCB at address 005CH with which exactly one file can be opened. The application manages further files via additional FCBs in its own address space. FCBs are stored in the directory area on the storage medium, copied to the main memory when a file is opened and written back when closed.