MODERN OPERATING SYSTEMS Third Edition ANDREW S

Slides:



Advertisements
Similar presentations
Chapter 6 File Systems 6.1 Files 6.2 Directories
Advertisements

Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 4 : File Systems What is a file system?
File Systems.
Chapter 10: File-System Interface
Operating Systems File Systems CNS 3060.
1 Pertemuan 21 Sistem File Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File System Implementation: beyond the user’s view A possible file system layout on a disk.
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
File Systems Implementation
File Systems Topics –File –Directory –File System Implementation Reference: Chapter 5: File Systems Operating Systems Design and Implementation (Second.
File Systems. 2 Storing Information Applications can store it in the process address space Why is it a bad idea? –Size is limited to size of virtual address.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
Chapter 4 File Systems Management and Optimization Example File Systems.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Ceng Operating Systems
Chapter 6 File Systems 6.1 Files 6.2 Directories
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
CS 333 Introduction to Operating Systems Class 17 - File Systems Jonathan Walpole Computer Science Portland State University.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
File System Implementation
Chapter 4 File Systems Files Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Chapter 8 File Management
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
Operating System Concepts and Techniques Lecture 17
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved Chapter 5 File Management File Overview.
CSC 322 Operating Systems Concepts Lecture - 19: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
CSC 322 Operating Systems Concepts Lecture - 20: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
CS333 Intro to Operating Systems Jonathan Walpole.
Module 4.0: File Systems File is a contiguous logical address space.
File Systems Security File Systems Implementation.
Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Some basic concepts and information on file systems Portions taken and modified from books by ANDREW S. TANENBAUM.
CS450/550 FileSystems.1 Adapted from MOS2E UC. Colorado Springs CS450/550 Operating Systems Lecture 6 File Systems Palden Lama Department of Computer.
Chapter 16 File Management The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander John.
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
CS 333 Introduction to Operating Systems Class 17 - File Systems Jonathan Walpole Computer Science Portland State University.
Annotated by B. Hirsbrunner File Systems Chapter Files 5.2 Directories 5.3 File System Implementation 5.4 Security 5.5 Protection Mechanism 5.6 Overview.
THE FILE SYSTEM Files long-term storage RAM short-term storage Programs, data, and text are all stored in files, which is stored on.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally FILE SYSTEM.
Directory Tree. Path Names (cont.) cp usr/ast/mailbox usr/ast/mailbox.bak and cp mailbox maibox.bak do the same thing if the working directory is /usr/ast.
操作系统原理 OPERATING SYSTEMS Chapter 4 File Systems 文件系统.
W4118 Operating Systems Instructor: Junfeng Yang.
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 5 Files.
Today topics: File System Implementation
Operating Systems Chapter 6: File Management
MODERN OPERATING SYSTEMS Third Edition ANDREW S
FileSystems.
Filesystems.
CS510 Operating System Foundations
File Systems Implementation
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
File System Implementation
Chapter 16 File Management
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

MODERN OPERATING SYSTEMS Third Edition ANDREW S MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

File Systems (1) Essential requirements for long-term information storage: It must be possible to store a very large amount of information. The information must survive the termination of the process using it. Multiple processes must be able to access the information concurrently. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

File Systems (2) Think of a disk as a linear sequence of fixed-size blocks and supporting reading and writing of blocks. Questions that quickly arise: How do you find information? How do you keep one user from reading another’s data? How do you know which blocks are free? Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

files Processes (threads), address spaces, files are the most important concepts in OS Files are logical units of information created by processes Similar to kind of address space File system Manage files: how they are structured, named, accessed, used, protected, implemented, etc

File naming Files are abstraction mechanism Two-part file name To store information on the disk and read it back When a process creates a file, it gives the file a name; and the file can be accessed by the name Two-part file name File extension: indicating characteristics of file In Unix, file extension is just convention; C compiler is exception In windows, file extensions specify which program “owns” that extension; when double clicking, program assigned to it is launched

Figure 4-1. Some typical file extensions. File Naming Figure 4-1. Some typical file extensions. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

File Structure Figure 4-2. Three kinds of files. (a) Byte sequence. (b) Record sequence. (c) Tree. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

File Types Regular Files: Directory ASCII files or binary files ASCII consists of lines of text; can be displayed and printed Binary, have some internal structure known to programs that use them Directory Files to keep track of files Character special files (a character device file) Related to I/O and model serial I/O devices Block special files (a block device file) Mainly to model disks

File Types Figure 4-3. (a) An executable file. (b) An archive. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

File Access File descriptor A file descriptor is a small integer representing a kernel-managed object that a process may read from or write to Every process has a private space of file descriptors starting at 0 By convention, 0 is standard input, 1 is standard output, and 2 is standard error System call: read() and write() to read from and write to filles named by file descriptors

Figure 4-4a. Some possible file attributes. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Struct stat Struct stat{ mode_t st_mode; // file type and mode (permission) ino_t st_ino; //inode number dev_t st_dev; //device number dev_t st_rdev; //device number (special) nlink_t st_nlink; //number of links uid_t st_uid; // user ID of owner gid_t st_gid; // group ID of owner off_t st_size; //size in bytes time_t st_atime; //time of last access ……}

File attributes drwxr-xr-x 2 root root 4096 Sep 24 2008 Unit2 drwxr-xr-x 2 root root 4096 May 26 19:21 a -rwxr-xr-x 1 root root 10930 Aug 5 22:49 a.out -rwxrwx--T 1 root root 81 Aug 2 2008 a.txt -rwxr-x--- 1 root root 81 May 26 19:20 b.txt -rwx------ 1 root root 81 Jul 30 19:28 c.txt -rwxr-xr-x 1 root root 11193 Jul 30 19:27 cp

File Owner Group Owner Everyone Else Write Permission Read Permission Execute Permission

UNIX File Owner Group Owner Everyone Else

File Operations The most common system calls relating to files: Create Delete Open Close Read Write Append Seek Get Attributes Set Attributes Rename Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Example Program Using File System Calls (1) . . . Figure 4-5. A simple program to copy a file. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Example Program Using File System Calls (2) Figure 4-5. A simple program to copy a file. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Hierarchical Directory Systems (1) Single-level directory system: The simpliest Figure 4-6. A single-level directory system containing four files. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Hierarchical Directory Systems (2) Figure 4-7. A hierarchical directory system. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Figure 4-8. A UNIX directory tree. Path Names Figure 4-8. A UNIX directory tree. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Path names Absolute path name Relative path name Start from root and are unique Relative path name Current working set: all path names not beginning at the root directory are taken relative to the working directory If current working directory is /usr/ast: then cp /usr/ast/mailbox /usr/ast/mailbox.bak Is: cp mailbox mailbox.bak

Path names Special Entries: “.” and “..” Dot refers to the current directory; dotdot refers to the parent directory (except root) cp /usr/lib/dictionary . cp /usr/lib/dictionary dictionary Cp /usr/lib/dictionary /usr/ast/dictionary

Directory Operations System calls for managing directories: Create Delete Opendir Closedir Readdir Rename Link Unlink Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Directory operation Hard link Symbolic link Linking allows a file to appear in more than one directory; increments the counter in the file’s i-node Symbolic link A name is created pointing to a tiny file naming another file

File System Implementation Users: How files are names, what operations are allowed on them, what the directory tree looks like Implementors How files and directories are stored, how disk space is managed and how to make every thing work efficiently and reliably

File System Layout File system are stored on disks. Most disks are divided up into several partitions Sector 0 is called MBR (master boot record), to boot the computer BIOS reads in and executes MBR, MBR locates the active partition, reads in the boot block, and execute The boot block reads in the OS contained in the partition

Figure 4-9. A possible file system layout. Superblock: contains all the key parameters about a file system; read into memory the booted or the FS is used Figure 4-9. A possible file system layout. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Contiguous Allocation Figure 4-10. (a) Contiguous allocation of disk space for 7 files. (b) The state of the disk after files D and F have been removed. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Contiguous Allocation Advantage: Simple to implement; to record the first block and length Easy to read; only one seek is needed Disadvantage: Fragmentation

Linked List Allocation Figure 4-11. Storing a file as a linked list of disk blocks. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Linked list allocation To keep each file as a linked list of disk blocks Advantage Only internal fragmentation Disadvantage Random access is difficult Adding a pointer at the head of block; extra overhead while copying

Linked List Allocation Using a Table in Memory Figure 4-12. Linked list allocation using a file allocation table in main memory. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Linked List Allocation Using a Table in Memory FAT-File Allocation Table Advantage Can take use of the whole block Random access is easy only to store the starting block number Disadvantage To keep the entire table in memory Can’t scale well

I-nodes Figure 4-13. An example i-node. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

i-nodes Advantage Disadvantage i-node need only be in memory when the corresponding file is open; file table grows linearly with the disk Disadvantage Each i-node has fixed size

Implementing Directories (1) Figure 4-14. (a) A simple directory containing fixed-size entries with the disk addresses and attributes in the directory entry. (b) A directory in which each entry just refers to an i-node. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Implementing Directories (2) Figure 4-15. Two ways of handling long file names in a directory. (a) In-line. (b) In a heap. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Shared Files (2) Figure 4-17. (a) Situation prior to linking. (b) After the link is created. (c) After the original owner removes the file. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Figure 4-20. Percentage of files smaller than a given size Disk Space Management Block Size (1) Figure 4-20. Percentage of files smaller than a given size (in bytes). Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Disk Space Management Block Size (2) Figure 4-21. The solid curve (left-hand scale) gives the data rate of a disk. The dashed curve (right-hand scale) gives the disk space efficiency. All files are 4 KB. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Keeping Track of Free Blocks (1) Figure 4-22. (a) Storing the free list on a linked list. (b) A bitmap. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

Keeping Track of Free Blocks (2) Figure 4-23. (a) An almost-full block of pointers to free disk blocks in memory and three blocks of pointers on disk. (b) Result of freeing a three-block file. (c) An alternative strategy for handling the three free blocks. The shaded entries represent pointers to free disk blocks. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The MS-DOS File System (1) Figure 4-31. The MS-DOS directory entry. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

FAT versions FAT comes up with 3 versions: FAT 12 FAT 16 FAT 32 Differ in how many bits a disk address contains Block size also varies: 512B, 1K, 2K,4K,…,32K

The MS-DOS File System (2) Figure 4-32. Maximum partition size for different block sizes. The empty boxes represent forbidden combinations. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The UNIX V7 File System (1) Figure 4-33. A UNIX V7 directory entry. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The UNIX V7 File System (2) Figure 4-34. A UNIX i-node. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

The UNIX V7 File System (3) Figure 4-35. The steps in looking up /usr/ast/mbox. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639

exercises Consider a disk with 1 MB per track, a rotation time of 8.33 msec, and an average seek time of 5 msec. Then what is the time to read a block of k bytes?

exercise Consider the idea behind Fig.4-21, for a disk with a mean seek time of 8msec, a rotational rate of 15,000 rpm, and 264,144 bytes per track. What are the data rate for block sizes of 1KB, 2KB and 4KB, respectively?

Exercise How many disk operations are needed to fetch the i-node for the file /usr/ast/courses/os/handout.t? Asume that the i-node for the root directory is in memory, but nothing else along the path is in memory. Also assume that all directories fit in one disk block.