CITS2002 Systems Programming |
CITS2002 | CITS2002 schedule | |||||
Organisation of File SystemsA clear and obvious requirement of an operating system is the provision of a convenient, efficient, and robust filing system. The file system is used not only to store users' programs and data, but also to support and represent significant portions of the operating system itself. Stallings introduces the traditional file system concepts of:
CITS2002 Systems Programming, Lecture 15, p1, 18th September 2023.
Organisation of File Systems, continuedToday, nearly all modern operating systems provide relatively simple file systems consisting of byte-addressable, sequential files. The basic unit of access, the record from Stallings's taxonomy, is the byte, and access to these is simply keyed using the byte's numeric offset from the beginning of each file (the size of the variable holding this offset will clearly limit a file's extent). The file-systems of modern operating systems, such as Linux's ext2, ext3, and ext4 systems and the Windows-NT File System (NTFS), support volumes with sizes up to 1 exbibyte (EiB) and files with sizes up to 16 tebibytes (TiB).
Operating Systems and DatabasesMore complex arrangements of data and its access modes, such as using search keys to locate individual fixed-length records, have been "relegated" to being supported by run-time libraries and database packages (see Linux's gdbm information). In commercial systems, such as for a large eCommerce system, a database management system (DBMS) may store and provide access to database information independent of an operating system's representation of files. The DBMS manages a whole (physical) disk-drive, or a dedicated partition, and effectively assumes much of the operating system's role in managing access, security, and backup facilities.
CITS2002 Systems Programming, Lecture 15, p2, 18th September 2023.
The File Management SystemThe increased simplicity of the file systems provided by modern operating systems has enabled a concentration on efficiency, security and constrained access, and robustness. Operating systems provide a layer of system-level software, using system-calls, to provide services relating to the provision of files. The consistent use of system-calls for this task, obviates the need for each application program to manage its own disk (space) allocation and access. Moreover, using system-calls to enter the kernel permits the OS to use file-system access as an opportunity to schedule processes. As a kernel-level responsibility, the file management system again provides a central role in resource (buffer) allocation and process scheduling.Ken Thompson, one of the original creators of Unix, was once asked what he'd do if he had it to do over again.
CITS2002 Systems Programming, Lecture 15, p3, 18th September 2023.
User RequirementsA further critical requirement in a multi-tasking, multi-user system is that the file management system meet users' requirements in the presence of different users. Subject to appropriate permissions, important requirements include:
CITS2002 Systems Programming, Lecture 15, p4, 18th September 2023.
Components of the File Management SystemStallings provides a generic depiction of the structure of the file management system:File System Software Architecture
CITS2002 Systems Programming, Lecture 15, p5, 18th September 2023.
The Role of Directory StructuresAll modern operating systems have adopted the hierarchical directory model to represent collections of files. A directory itself is typically a special type of file storing information about the files (and hence directories) it contains. Although a directory is "owned" by a user, the directory is truly owned by the operating system itself. The operating system must constrain access to important, and often hidden, information in the directory itself. Although the "owner" of a directory may examine and (attempt to) modify it, true modification is only permitted through OS system-calls affecting the internal directory structure. For example, deleting a file involves both deallocating any disk blocks used by that file, and removing that file's information from its container directory. If direct modification of the directory were possible, the file may become "unlinked" in the hierarchical structure, and thereafter be inaccessible (as it could not be named and found by name). In general, each directory is stored as a simple file, containing the names of files within it. The directory's "contents" may be read with simple user-level routines (introduced in Lecture 16).
CITS2002 Systems Programming, Lecture 15, p6, 18th September 2023.
File Information Structures - inodesEarly operating systems maintained information about each file in the directory entries themselves. However, the use of the hierarchical directory model encourages a separate information structure for each file. As an example, Unix refers to these information structures as inodes, accessing them by their integral inode number on each device (themselves referred to by two integral device numbers). Each information structure is accessed by a unique key (unique to the I/O device), and the role of the directory is now simply to provide <filename, inode> pairs. A distinct file-entry is identified by a <major-device-number, minor-device-number, inode> triple.
CITS2002 Systems Programming, Lecture 15, p7, 18th September 2023.
File Information Structures - inodes, continued
CITS2002 Systems Programming, Lecture 15, p8, 18th September 2023.
File Allocation Methods - ContiguousOf particular interest is the method that the basic file system uses to place the logical file blocks onto the physical medium (for example, into the disk's tracks and sectors on on spinning, magnetic HD).Contiguous File Allocation
CITS2002 Systems Programming, Lecture 15, p9, 18th September 2023.
File Allocation Methods - ChainedThe opposite extreme to contiguous allocation is chained allocation. Here, the blocks allocated to a file form a linked list (or chain) and, as a file's length is extended (by appending to the file), a new block is allocated and linked to the last block in the file:Chained File Allocation
CITS2002 Systems Programming, Lecture 15, p10, 18th September 2023.
File Allocation Methods - IndexedThe file allocation method of choice in both Unix and Windows is the indexed allocation method. This method was championed by the Multics operating system in 1966. The file-allocation table contains a multi-level index for each file - just as we have seen in the use of inodes, which contain direct pointers to data blocks, and pointers to indirection blocks (which point to more data blocks).Indexed Allocation with Block Portions
CITS2002 Systems Programming, Lecture 15, p11, 18th September 2023.
|