Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems File systems

Similar presentations


Presentation on theme: "Operating Systems File systems"— Presentation transcript:

1 Operating Systems File systems
phones off (please) CSCI2413 Lecture 7 Operating Systems File systems

2 Lecture Outline File management File Types File Access File Structure
Unix file types File Access File Structure Disk Construction File Allocation Tables © De Montfort University, 2004/5 CSCI L7

3 File Management Files exist to store information and allow it to be retrieved later. The OS must set up a management system to provide facilities for general users to carry out a range of file handling processes such as: create a file, delete a file, copy a file identify a file type, name a file, rename a file, display the contents of a file, create/remove/list logical groups of files e.g. folders, directories specify locations of files protect files from unauthorised access. © De Montfort University, 2004/5 CSCI L7

4 File Management Also programmers will want to carry out file handling processes such as: Open: a file Close: a file Read: data from a file Write: data to a file Seek: a particular place in a file for subsequent data transfer. © De Montfort University, 2004/5 CSCI L7

5 File System, Hierarchical or Tree structure
© De Montfort University, 2004/5 CSCI L7

6 File Types A file may have a specific type or purpose, e.g.
regular files, directories, character/block special files, pipes Some systems have specific types for things like ASCII (text) files executable (machine code) files File types may be enforced MS-DOS executable must have ‘.exe’ extension or not (they are just a hint to the user) UNIX text files may have ‘.txt’ extension File types may have associations Apple Mac types associate a file with its creator © De Montfort University, 2004/5 CSCI L7

7 File Types – Name, Extension
© De Montfort University, 2004/5 CSCI L7

8 Unix File Types Four basic types: Regular Files Directory Files
may contain text, a program, or other data, either in ASCII, in the numerical range 0 to 127, i.e. in the 7-bit range or a binary file, whose bytes can be of all possible values 0 to 255, in the 8-bit range. Directory Files A directory containing files within a directory E.g. directory x may contain a, b and c, and that b is a directory, containing files u and v. b can be viewed as a directory, containing files and as a file itself. © De Montfort University, 2004/5 CSCI L7

9 Unix File Types …. Device Files Link Files
In Unix, physical devices (printers, terminals etc.) are represented as ``files.'' In his way, the same read() and write() functions used to read and write real files can also be used to read from and write to these devices. Link Files new name for another file suppose we have a file X, and type ln X Y If we then run ls, it will appear that a new file, Y, has been created, as a copy of X, © De Montfort University, 2004/5 CSCI L7

10 File Access Methods There are two distinct classes of access method
sequential access suited to magnetic tape devices the information in a file (bytes or records) can only be written at the end (appended) or read in sequential order random access suited to hard disks bytes or records can be read or written in any order sometimes this is implemented by each read and write operation specifying a position parameter, or © De Montfort University, 2004/5 CSCI L7

11 File System Structure Hard disks provide the bulk of secondary storage on which a file system is maintained to improve input / output efficiency, I/O transfers are performed in units of blocks Each block consists of one or more physical hard disk sectors typical physical sector sizes vary from 32 to 4K bytes usually, particularly on PC’s, sectors are 512 bytes Hard disks have two important characteristics blocks can be read, modified and written (in place) blocks can be directly accessed in any order © De Montfort University, 2004/5 CSCI L7

12 File System Layers In order to provide convenient and efficient user access to the disk, the operating system imposes a file system structure this generally comprises a number of layers to insulate the logical structure from device dependencies application programs logical file system (files, directories, etc) basic file system (block read & write) I/O control (interrupts, device drivers) hardware devices © De Montfort University, 2004/5 CSCI L7

13 Disk Construction A hard disk consists of a number of platters
made of aluminium or glass with a thin magnetic film on the surface common platter diameters range from inches Information is stored magnetically on both surfaces (sides) of each platter The platters rotate at a fixed rate on the spindle e.g. modern PC drives rotate at 5,400 or 7,200 rpm © De Montfort University, 2004/5 CSCI L7

14 Read / Write Heads Each surface has a read/write head to access the magnetic fields the heads are mounted on arms and their movement is controlled by an actuator all the heads move together side view r/w heads arms actuator The heads do not touch the surface, but ‘fly’ a very small distance above the surface the fly height typically between around 0.2 to 0.07 mm © De Montfort University, 2004/5 CSCI L7

15 The Disk Surface The surface of a disk is logically divided into concentric circular tracks 1,000’s are now common The surface is also divided into segments a track through a particular segment is a sector note: often the term sector is confusingly used to refer to both segments and sectors! on typical PC disks, each sector holds 512 bytes © De Montfort University, 2004/5 CSCI L7

16 data capacity of a disk is described best by:
Disk Capacity = Cylinders * Heads * Sectors * (# bytes / disk block) A typical example for a 2.1 GB IDE disk on a Linux-based PC would be: C/H/S = 1024/64/63 Disk Capacity = 1024 * 64 * 63 * 512 bytes/block = bytes = 2.11 gigabytes © De Montfort University, 2004/5 CSCI L7

17 File Allocation Tables
The FAT is an index array of linked-list block numbers kept in its own disk block the FAT contents are critical to finding all file blocks, so it is (usually) held twice at the start of each partition the root directory immediately follows the FATs The directory entry holds the start block of a file the FAT entry indexed by that block number contains the block number of the next block in the chain there is a special value to signify end of file Special values signify free blocks and bad blocks © De Montfort University, 2004/5 CSCI L7

18 File Systems in Unix In Unix, the files are organized into a tree structure with a root named by the character '/'. The first few levels of the tree look like this: © De Montfort University, 2004/5 CSCI L7

19 Summary File system, The system that an operating system or program uses to organize and keep track of files. For example, a hierarchical file system is one that uses directories to organize files into a tree structure. Although the operating system provides its own file management system, you can buy separate file management systems. These systems interact smoothly with the operating system but provide more features, such as improved backup procedures and stricter file protection. © De Montfort University, 2004/5 CSCI L7


Download ppt "Operating Systems File systems"

Similar presentations


Ads by Google