Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.

Similar presentations


Presentation on theme: "Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure."— Presentation transcript:

1 Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure  Protection  File System implementation  File-system structure  Allocation Methods  Free-space Management  Directory Implementation  Recovery, Efficiency, and Performance

2 Operating Systems 2 K. Salah File Attributes Name – only information kept in human-readable form. Type – needed for systems that support different types. Location – pointer to file location on device. Size – current file size. Protection – controls who can do reading, writing, executing. Time, date, and user identification – data for protection, security, and usage monitoring. Information about files are kept in the directory structure, which is maintained on the disk.

3 Operating Systems 3 K. Salah File Operations create write read reposition within file – file seek delete truncate open(F i ) – search the directory structure/descriptor on disk for entry F i, and move the content of entry to memory. close (F i ) – move the content of entry F i in memory to directory structure/descriptor on disk.

4 Operating Systems 4 K. Salah File Types – name, extension

5 Operating Systems 5 K. Salah File Structure of Data within Data Blocks  None - sequence of words, bytes  Simple record structure  Lines  Fixed length  Variable length  Tree of fixed or variable records with a key for each record.  Who decides:  Operating system  Program

6 Operating Systems 6 K. Salah Access Methods Sequential Access Tape Model. Reading records in order. read next write next reset Direct or Random Access Disk Model. Reading records in order and out of order. read n write n position to n read next write next Most files in modern OS are direct access.

7 Operating Systems 7 K. Salah Memory-Mapped Files  Some OS provides map and unmap system calls.  map will map the file into the address space at the virtual address. System calls like open, read, seek are not applicable.  Eliminates the need for I/O, thus making it easier to program.  Problems  Hard to know the size of the file in advance  Conflicts arise when sharing files between processes  Example: one process uses map and another uses open, read, write.  How to deal with huge files that are bigger than a segment or the whole virtual address space.

8 Operating Systems 8 K. Salah Directory Structure  A collection of nodes containing information about all files.  Both the directory structure and the files reside on disk. F 1 F 2 F 3 F 4 F n Directory Files

9 Operating Systems 9 K. Salah Information in a Device Directory Name Type Address Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID (who pays) Protection information (discuss later)

10 Operating Systems 10 K. Salah Operations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system

11 Operating Systems 11 K. Salah Actual File Size In Windows, disk block is 4KB In Unix, disk block is 512B “Size” of file reflects the actual size of data. “Size on disk” which is multiple of data blocks. Ex, if you create a text file with “xyz” with notepad, size of file will show 3, while “Size on disk” will show 4KB.

12 Operating Systems 12 K. Salah Organize the Directory (Logically) to Obtain  Efficiency – locating a file quickly.  Naming – convenient to users.  Two users can have same name for different files.  The same file can have several different names.  Grouping – logical grouping of files by properties, (e.g., all Pascal programs, all games, …)  Directory structure:  Single-level: A single directory of all users  Two-level: Separate directory for each user  Tree-structured: Most common

13 Operating Systems 13 K. Salah Tree-Structured Directories  Efficient searching  Grouping Capability  Absolute or relative path name  Current directory (working directory)  cd /spell/mail/prog  type list  Deleting “mail”  deleting the entire subtree rooted by “mail”.

14 Operating Systems 14 K. Salah Shared Files/Directories  Symbolic or soft link  A file/directory is a pointer (contains the pathname) to another file/directory,  e.g., ln –s /etc/classes/ics431/class softclass  A new i-node is created for softclass  Takes longer to lookup as the path is traversed  The file pointed to can be deleted or changed  Backup might do multiple copies  Good for linking files on other machines  Hard link  The file/directory points to the same file/directory-structure or I- node of the other file/directory.  e.g., ln /etc/classes/ics431/class hardclass  No i-node is created. Only entry in the i-node of directory which hardclass is under  Faster for lookup  Has an owner issue  Need to keep a count in the structure for file deletion 

15 Operating Systems 15 K. Salah Protection File owner/creator should be able to control: –what can be done –by whom Types of access –Read –Write –Execute –Append –Delete –List

16 Operating Systems 16 K. Salah Access Lists and Groups Mode of access: read, write, execute Three classes of users RWX a) owner access 7  1 1 1 RWX b) groups access 6  1 1 0 RWX c) public access1  0 0 1 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. ownergrouppublic chmod761game Attach a group to a file chgrp G game

17 Operating Systems 17 K. Salah File-System Implementation  Contiguous Allocation  Each file occupies a set of contiguous blocks on the disk.  Simple – only starting location (block #) and length (number of blocks) are required.  Random access.  Wasteful of space (dynamic allocation problem).  Files cannot grow.  Linked Allocation  Indexed Allocation

18 Operating Systems 18 K. Salah Linked Allocation  Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk.  Simple – need only starting address  Free-space management system – no waste of space except for pointers  No random access  File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2.  A table used as a linked list keeping track of all available and used blocks. See Fig. 12- 6.

19 Operating Systems 19 K. Salah Indexed Allocation  Brings all pointers together into the index block. In Unix called (i- node).  Random access  Dynamic allocation without external fragmentation, but have overhead of index block.  Wasted space for index block. Worse than linked allocation.  How big should the index block be?

20 Operating Systems 20 K. Salah Use of Multi-level Index – Unix i-node

21 Operating Systems 21 K. Salah Where is the path stored in the inode of a softlink file? Where is list of file names in a directory inode is stored?

22 Operating Systems 22 K. Salah Directory Implementation  Linear list of file names with pointer to the data blocks.  simple to program  time-consuming to execute  Hash Table – linear list with hash data structure.  decreases directory search time  collisions – situations where two file names hash to the same location  fixed size

23 Operating Systems 23 K. Salah Efficiency and Performance  Efficiency dependent on:  disk allocation and directory algorithms  types of data kept in file’s directory entry  Performance  disk cache – separate section of main memory for frequently used blocks  free-behind and read-ahead – techniques to optimize sequential access  improve PC performance by dedicating section of memory as virtual disk, or RAM disk.

24 Operating Systems 24 K. Salah Caching and Recovery Various Disk-Caching Locations:  Consistency checker – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies.  Use system programs to back up data from disk to another storage device (USB disks, tapes, or Cloud Computing dropbox).  Recover lost file or disk by restoring data from backup.  NTFS Features: Logging or journaling, Encryption, Compression, Larger sizes than FAT, but more overhead (space and time).


Download ppt "Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure."

Similar presentations


Ads by Google