A File ControlBlock ( FCB ) is a file systemstructure in which the state of an open
Question:
A File ControlBlock (FCB) is a file systemstructure in which the state of an open file ismaintained. A FCB is managed by the operating system, but itresides in the memory of the program that uses the file, not inoperating system memory. This allows a process to have as manyfiles open at one time as it wants to, provided it can spare enoughmemory for an FCB per file.
The FCB originates from CP/M and is also present inmost variants of DOS, though only as a backwards compatibilitymeasure in MS-DOS versions 2.0 and later. A full FCB is36 bytes long; in early versions of CP/M, it was 33 bytes. Thisfixed size, which could not be increased without breakingapplication compatibility, lead to the FCB's eventual demise as thestandard method of accessing files.
The meanings of several of the fields in the FCB differ betweenCP/M and DOS, and also depending on what operation is beingperformed.
The Global DescriptorTable (GDT) is a data structureused by Intel x86-family processors starting withthe 80286 in order to define the characteristics of thevarious memory areas used during program execution, including thebase address, the size, and access privileges like executabilityand writability. These memory areas arecalled segments in Intel terminology.
The GDT can hold things other than segmentdescriptors as well. Every 8-byte entry in the GDT is adescriptor, but these descriptors can be references not only tomemory segments but also to Task State Segment (TSS),Local Descriptor Table (LDT), or Call Gate structures inmemory. The last ones, Call Gates, are particularly important fortransferring control between x86 privilege levels although thismechanism is not used on most modern operating systems.
There is also the concept of a Local DescriptorTable (LDT). Multiple LDTs can be defined in the GDT, butonly one is current at any one time: usually associated with thecurrent Task. While the LDT contains memory segments which areprivate to a specific program, the GDT contains global segments.The x86 processors have facilities for automatically switching thecurrent LDT on specific machine events, but no facilities forautomatically switching the GDT.
Every memory access which a program can perform always goesthrough a segment. On the 80386 processor and later,because of 32-bit segment offsets and limits, it ispossible to make segments cover the entire addressable memory,which makes segment-relative addressing transparent to theuser.
In order to reference a segment, a program must use its indexinside the GDT or the LDT. Such an index is calleda segmentselector or selector in short. Theselector must generally be loaded into a segmentregister to be used. Apart from the machine instructionswhich allow one to set/get the position of the GDT (and ofthe Interrupt Descriptor Table) in memory, every machineinstruction referencing memory has an implicit Segment Register,occasionally two. Most of the time this Segment Register can beoverridden by adding a Segment Prefix before the instruction.
The Interrupt DescriptorTable (IDT) is a data structure usedby the x86 architecture to implement an interruptvector table. The IDT is used by the processor to determinethe correct responseto interrupts and exceptions.
The details in the description below apply specifically to thex86 architecture and the AMD64 architecture. Otherarchitectures have similar data structures, but may behavedifferently.
Use of the IDT is triggered by three types of events: hardwareinterrupts, software interrupts, and processor exceptions, whichtogether are referred to as interrupts. The IDTconsists of 256 interrupt vectors–the first 32 (0–31 or0x00–0x1F) of which are reserved for processor exceptions.
The Program Segment Prefix (PSP) is adata structure used in DOS systems to store the state ofa program. It resembles the Zero Page inthe CP/M operating system. The PSP has the followingstructure:
Offsetimages | Size | Contents |
00h-01h | 2 bytes (code) | CP/M-80-like exit (always contains INT 20h)[1] |
02h-03h | word (2 bytes) | Segment of the first byte beyond the memory allocated to theprogram |
04h | byte | Reserved |
05h-09h | 5 bytes (code) | CP/M-80-like far call entry into DOS, and program segmentsize[1][2] |
0Ah-0Dh | dword (4 bytes) | Terminate address of previous program (old INT 22h) |
0Eh-11h | dword | Break address of previous program (old INT 23h) |
12h-15h | dword | Critical error address of previous program (old INT24h) |
16h-17h | word | Parent's PSP segment (usually COMMAND.COM -internal) |
18h-2Bh | 20 bytes | Job File Table (JFT) (internal) |
2Ch-2Dh | word | Environment segment |
2Eh-31h | dword | SS:SP on entry to last INT 21h call (internal) |
32h-33h | word | JFT size (internal) |
34h-37h | dword | Pointer to JFT (internal) |
38h-3Bh | dword | Pointer to previous PSP (only used by SHARE in DOS 3.3 andlater) |
3Ch-3Fh | 4 bytes | Reserved |
40h-41h | word | DOS version to return (DOS 4 and later, alterable via SETVER inDOS 5 and later) |
42h-4Fh | 14 bytes | Reserved |
50h-52h | 3 bytes (code) | Unix-like far call entry into DOS (always contains INT 21h +RETF) |
53h-54h | 2 bytes | Reserved |
55h-5Bh | 7 bytes | Reserved (can be used to make first FCB into an extendedFCB) |
5Ch-6Bh | 16 bytes | Unopened Standard FCB 1 |
6Ch-7Fh | 20 bytes | Unopened Standard FCB 2 (overwritten if FCB 1 is opened) |
80h | 1 byte | Number of bytes on command-line |
81h-FFh | 127 bytes | Command-line tail (terminated by a 0Dh)[3][4] |
The PSP is most often used to get the command linearguments of a DOS program; for example, the command "FOO.EXE/A /F" executes FOO.EXE with the arguments '/A' and '/F'.
If the PSP entry for the command line length is non-zero and thepointer to the environment segment is neither 0000h nor FFFFh,programs should first try to retrieve the command line fromthe environment variable %CMDLINE% before extractingit from the PSP. This way, it is possible to pass command lineslonger than 126 characters to applications.
The segment address of the PSP is passed in the DS register whenthe program is executed. It can also be determined later by usingInt 21h function 51h or Int 21h function 62h. Either function willreturn the PSP address in register BX.[5]
Alternatively, in .COM programs loaded atoffset 100h, one can address the PSP directly just by usingthe offsets listed above. Offset 000h points to thebeginning of the PSP, 0FFh points to the end, etc.
Accounting Information Systems
ISBN: 9780132871938
11th Edition
Authors: George H. Bodnar, William S. Hopwood