Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating System Concepts and Techniques Lecture 17

Similar presentations


Presentation on theme: "Operating System Concepts and Techniques Lecture 17"— Presentation transcript:

1 Operating System Concepts and Techniques Lecture 17
Information management-1* Foundations and UNIX/Linux File System M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: or * Information management is not usually covered in the first university course of operating systems

2 Storage media Disk pack: An structured hardware consisting of
Many plates, two surfaces per plate, many same capacity tracks on each surface, many same capacity sectors on each track Disk model Each partition Partition Partition Partition k Sector 1 Sector 1 Sector … … … Sector mn ... Track Track m-1

3 File An structure of vast amount of information to be stored on persistent media, could be Collection of bytes ASCII Binary Collection of records Tree structure File types Regular: user files Directories: meta data about files Special Files: for example, I/O files for printer Block special: files for tapes, disks

4 File Attributes/Data/operations/access
Each file consists of: Attributes: owner, creator, password, Archive/system, Hidden, lock, temporary, random access, ASCII/Binary, time of last access, creation time, key length, key position, record length, max size, current size, time of last change etc. Data Valid operations are: create, delete, open, close, read, write, append, seek, get attributes, set attributes, rename File access: Sequential, random

5 Storage allocation Contiguous allocation: a file (or directory) is considered a chunk of data that must be stored in a contiguous data area of the storage device Size of each file is a multiple of blocks Block size is a power of two sectors Advantages: address calculation is simple For sequential access prefetch is possible Disadvantage External fragmentation May require frequent defragmentation Disk attributes, metadata, … File 1 File 2 File i Unallocated area

6 Storage allocation... Chained allocation: Data blocks of a file need not take a contiguous area, but they are chained together Advantage No external fragmentation Disadvantages: Address calculation is difficult Random access is time consuming and needs excessive disk access Disk attributes, metadata, …

7 Storage allocation... Indexed allocation: any block of data can sit in any block frame of disk Index table(s), will make note of which block is stored where, it uses disk block numbers instead of the physical address of the block; options are: Only one table: like FAT One table for every file or directory: like UNIX Advantages: No external fragmentation index table is usually in the main memory thus rendering both sequential and random access to files and directories efficient

8 Other topics Free space management Bad block management
Chained free pieces Bitmap Index table Bad block management Substitute sectors File of bad blocks

9 Directory tree/directory
Directory tree: the organization of files and directories, on a volume, in the form of a tree Directory: a folder of files and subdirectories and their handles Figure 1 Directory operations: Create, delete, opendir, closedir, readdir, rename, link, unlink B C R S W X A D P Q L K Directory File

10 UNIX File System(USF) Structure of a partition is:
Superblock has attributes and metadata of the file system itself; size in blocks of the file system; size in blocks of the i-node list, number of free blocks and i-nodes, free block list Indexed allocation is used to allocate available blocks to file and directory data. Every file or directory has its own index table The index table is a special one, called index-node (or i-node for short) The length of all i-nodes is the same, usually 64 bytes and the total number If total number of i-nodes is say 1024, then the space requirement for this area is 64*1024 bytes or 64 kilo bytes Boot block Superblock i-node list Data blocks

11 UNIX File System(USF)…
Root does not have a name, instead its i-node is the first i-node of the i-node list At computer start/restart root directory becomes current directory The last 4 rows of I-node needs special attention File mode Flags for file type, execution, owner permissions, Group permissions, and other permissions Link count Number of links to this i-node OwnerID ID of the owner GroupID ID of the group of the owner of this file File size File size in bytes Last accessed Time of last access Last modified Time of last modification Inode modified Time of last i-node modification Direct addresses Ten direct addresses Single indirect addresses Pointer to a block of addresses Double indirect addresses Triple indirect addresses Some information of i-node

12 I-node In memory i-node is 64 bytes; the rest is on disk extensions
Ten block address for the file data (3 bytes each) One single indirect One double indirect One triple indirect . Data blocks Table of pointers File or directory attributes 10 Direct pointers to data blocks Single indirect Double indirect Triple indirect

13 Largest file size Varies with: block sizes; assume 1K
Size of disk addresses used; assume 4 bytes Direct addresses: total 10K Single indirect addresses: total 256K Double indirect addresses: total 256*256K Triple indirect addresses: total 256*256*256K Overall total:( * *256*256)K Not too big, but a larger block size allows a larger file

14 (b) Directory C’s data of Figure 1 Root directory’s data of Figure 1
Directory data 2 bytes bytes Format of directory data records I-node number File name 1 00 5 A 8 B 6 C 4 D 6 1 00 12 S 9 R (b) Directory C’s data of Figure 1 Data block no 120 Root directory’s data of Figure 1 Data block no 100 Figure 2: The structure of directory data blocks

15 Looking for a file’s data
How can the file Q’s data storage location be found? The operating system goes to current directory’s i-node and locates Q and its i-node number Suppose file Q is not in the current directory but its absolute path is say /C/S/Q The file system will access i-node number 1 and search for the root’s data location (data block no 100, Figure 2a) It looks for C and its i-node number which is 6; using i-node number six it looks for directory C’s data block (say no. 120) In this databblock (Figure 2b) the file system looks for S and its i-node number (say 12) It continues this process until Q’s i-node number is found; using this i-node the file system searches for Q’s data storage blocks.

16 Advantage/Disadvantage
Advantages: i-nodes can be shared while in main memory, hence file sharing Fast processing Disadvantage: i-node updates are not instant, in memory i-node may be changed while on disk is something different

17 Summary Caches and main memories lose their contents as soon as the computer is turned off We must store persistent information on persistent devices The well thought out organization of information in secondary storage, especially in light of its vastness, is extremely crucial This responsibility lies with the file system Many file systems have been developed to address this task In this lecture, the design foundation of file systems was studied The design details of a major file systems, the UNIX File System (UFS) was thoroughly investigated

18 Find out The differences between Unix file system and Linux file system All the information that is stored in a 64 byte i-node Why the name of files and subdirectories of a directory should not be stored within the i-node of that directory and they have to be stored in data blocks? The difference between a file system and a file How can a file be organized to represent all bad blocks of a disk What is the usage of a substitute sector

19 Any questions?


Download ppt "Operating System Concepts and Techniques Lecture 17"

Similar presentations


Ads by Google