File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

File Management.
Operating Systems File Management.
Chapter 4 : File Systems What is a file system?
File Systems.
File Management Lecture 3.
Allocation Methods - Contiguous
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Operating Systems File Systems CNS 3060.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File System Implementation
Operating Systems File Systems (in a Day) Ch
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
Ceng Operating Systems
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data structures Placement of files on disk.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Operating Systems File systems
File System Implementation
Chapter 8 File Management
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
hardware and operating systems basics.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Dr Damitha Karunaratna University of Colombo school of computing
File Implementation. File System Abstraction How to Organize Files on Disk Goals: –Maximize sequential performance –Easy random access to file –Easy.
Chapter pages1 File Management Chapter 12.
1Fall 2008, Chapter 11 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
CS 346 – Chapter 12 File systems –Structure –Information to maintain –How to access a file –Directory implementation –Disk allocation methods  efficient.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Operating System Concepts and Techniques Lecture 17
NETW3005 File System Interface. Reading For this lecture, you should have read Chapter 10 (Sections 1-5) and Chapter 11 (Sections 1-4). NETW3005 (Operating.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
10/22/2015CST Operating Systems1 Operating Systems CST 352 File Systems.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
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.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Operating System Concepts Part II Department of Computer Science Southern Illinois University Edwardsville Spring, 2009 Dr. Hiroshi Fujinoki
12/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
Css430 file-system implementation1 CSS430 File-System Implementation Textbook Ch12 These slides were compiled from the OSC textbook slides (Silberschatz,
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.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
Chapter 1 (PART 2) Operating System Concepts Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki.
File Systems.  Issues for OS  Organize files  Directories structure  File types based on different accesses  Sequential, indexed sequential, indexed.
ECE 456 Computer Architecture Lecture #9 – Input/Output Instructor: Dr. Honggang Wang Fall 2013.
Part III Storage Management
W4118 Operating Systems Instructor: Junfeng Yang.
OS Boot Sequence and File System (implication to “Boot Sector Viruses”) Department of Computer Science Southern Illinois University Edwardsville Spring,
Introduction to Kernel
Chapter 11: File System Implementation
Filesystems.
CENG334 Introduction to Operating Systems
CS510 Operating System Foundations
Modern PC operating systems
Chapter 16 File Management
Department of Computer Science
OS Boot Sequence and File System
Operating System Concepts
Operating System Concepts
Chapter 12: File-System Implementation CSS503 Systems Programming
OS Boot Sequence and File System
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314 Operating Systems File_System/001

CS 314 Operating Systems What is “file system”? Hard-Disk Drive Unit (Hardware) Device Drivers File System Semantics & Logical Structure Users Software implementation of files and directories CD-ROM Drive Unit Device Drivers Semantics Logical Structure Software implementation of files and directories Hide implementations details (absorb various types in hardware device) e.g., “Read 100 bytes from “my.txt” Provide users with high-level manipulations for files File_System/002 File system is an OS component that manages files for users (or applications) Hide implementation

CS 314 Operating Systems Question: Why not just memory (why do we need “files”)?  Information must survive after a system is shut down  Capacity of physical memory is usually limited Why do we need file system (or files)? (We can’t perform big application) Paging  IPC through memory (shared memory) is not easy IPC through a file (pipe) is easier  Identifying data you want to access is easy You can give a file name to a set of data You don’t have to use a pointer to access data (OS (i.e., file system) does this for you)  Manipulating set of data is easy in file - save- copy - concatenate- delete - move File_System/003

CS 314 Operating Systems The five essential functions in a file system  Storing files a unit of data to be manipulated Regular files: Directories: A special file that gives a tree-like hierarchical structure to ordinary files  Free-disk space management  Disk space allocation for each file (FAT, i-node, etc) (bit-map, array, linked-list) Similar to “free-memory management” File_System/004  User interface (let human users manipulate files) create, read, write, append, copy, move, etc.  Access control (Who can read, write, execute, delete a file?)

File_System/005 Categories of files Files Directories Character Files Block Files Ordinary Files Special Files Ordinary Files Special Files Files for which unit of I/O is “character” Files for which unit of I/O is “record” Regular Files Files for which I/O can be performed I/O Files Executable Files For saving your data For saving your data As the interface to an I/O device As the interface to an I/O device Tree Files CS 314 Operating Systems

File_System/006 Hierarchical Directory Systems = Directory = File (ordinary file) Root Directory Files are a leaf-node Directories can have files and/or directories Directories can be a leaf-node Ownership of a directory is usually inherited to child directories Each drive (file system) starts with the root directory (user data will be stored there) Most of modern OSes use HDS CD (Change Directory) CWD (Current Working Directory)

Executable File File_System/007 Executable Files File Header Program Codes Data & Constants Relocation bits Symbol Table     Magic Number  Program code size  Data size  BSS size  Symbol table size  Entry point  Flags CPU Program codes (machine codes) CS 314 Operating Systems

file CS 314 Operating Systems File_System/008 Internal File Organizations How does the contents in a file looks from user’s view? - You request data from file. The file system returns the requested data as a sequence of bytes. - No structure in returned data (OS does not care the contents. It’s all up to you.)  Character Sequence (A.K.A “Byte Sequence”)  Block Sequence (A.K.A. “Record Sequence”) - Contents in a file are organized as “records” - File read/write is in the unit of “record” Example: fprintf (name, address, phone_num, age); “record” file record Example: read (file_ID, buffer, number_bytes);

CS 314 Operating Systems File_System/010 Two access methods to files 1. Sequential Access Data in a file can be accessed from the beginning of a file to the end Data is accessed always in the same order Example: file saved on a tape Access Head

CS 314 Operating Systems File_System/ Random Access Data in a file can be accessed from any where within a file You can specify data in a file (usually as “record”) Example: files saved on hard disk and floppy disk Disk File Data Access Head Two access methods to files

Disk-Drive Unit CS 314 Operating Systems (from CS312 Computer Architecture) File_System/017 Disk (physical) Track (logical) sector (logical) Hardware Organization (Disk) Motor spindle (physical)

CS 314 Operating Systems File_System/018 File System Implementation  Sector allocations to files & managing sector allocations to files Contiguous allocation Non-Contiguous allocation (a) File space allocations (b) Managing space allocations Linked-list (“chained”) Indexed

CS 314 Operating Systems (from CS312 Computer Architecture) File_System/012 File System Implementation  Structure of a file system Disk (Disk Platter) Physical Drive Capacity

CS 314 Operating Systems File_System/013 Logical internal format of a disk drive  Structure of a file system Physical Drive Capacity MBR Partition Table Partition #1Partition #N    Logical Drive Size of a partition The first sector for a partition The last sector for a partition Type of file system used for this partition

File_System/014 File System Implementation  Structure of a file system Physical Drive Capacity MBR Partition Table Partition #1Partition #N    Logical Drive Boot Block Super Block Free Space Management File Allocation Information The Root Directory Other files & directories Logical Drive CS 314 Operating Systems

File_System/015 System Boot Sequence  You turn on power  CPU jumps to the beginning of BIOS ROM  CPU executes POST and initializes hardware - Memory access latency, initialize video card, etc.  CPU executes BIOS routine to load MBR  CPU jumps to the routine in MBR  MBR contains a routine to check the partition table - Find out which logical drive is the system boot drive - Load the boot block of the boot drive and CPU jumps to it - The boot block contains a routine to start OS CS 314 Operating Systems

Logical Drive #0 (the first logical drive) CS 314 Operating Systems File_System/016 File System Implementation  Structure of a file system Physical Drive MBR Partition Table Partition #1Partition #N    Logical Drive Boot Block Super Block Free Space Management File Allocation Information The Root Directory Other files & directories Power-On Hardware Software This is the file system

CS 314 Operating Systems File_System/019 File System Implementation (1) Contiguous sector allocations * Microsoft calls “block” as “cluster” File A (5 blocks) File B (4 blocks) File C (12 blocks) File D (8 blocks) File E (7 blocks) Advantages  Easy implementation File Name1st blockFile size File A05 blocks File B54 blocks File C912 blocks File D218 blocks File E297 blocks  Fast access Blocks (sectors) are always contiguous Minimum head seek time Block* (a collection of sectors)

CS 314 Operating Systems File_System/020 File System Implementation (1) Contiguous sector allocations File A (5 blocks) File B (4 blocks) File C (12 blocks) File D (8 blocks) File E (7 blocks) Disadvantages  Halls of “free blocks” (external fragmentation) Disk space will be wasted by halls  Compaction (de-fragmentation) Expensive operation (for large disks)

CS 314 Operating Systems File_System/021 File System Implementation

CS 314 Operating Systems File_System/022 File System Implementation (2) Non-Contiguous sector allocations A file Need to manage sector allocations File Allocation Table (FAT) Linked-list of disk blocks i-node Advantages No external fragmentation (Windows’ approach) (UNIX’s approach)

CS 314 Operating Systems File_System/023 File System Implementation File Name1st blockFile size File A115 blocks A file NULL Linked-list of blocks

File Allocation Table (FAT) CS 314 Operating Systems File_System/024 File System Implementation File Name1st blockFile size File A115 blocks A file File Allocation Table

CS 314 Operating Systems File_System/025 File System Implementation File NamePointerFile size File A5 blocks A file i-node What if a file is very large? If # of blocks needed is more than i-node?

CS 314 Operating Systems File_System/026 File System Implementation File NamePointerFile size File A5 blocks A file i-node Pointer

Disk Drive (HDD) File_System/027 Memory-Mapped Files Concept Try to access files as memory Virtual Address Space File Disk Sector (or a block of sectors) CS 314 Operating Systems

File_System/028 Memory-Mapped Files Concept Try to access files as memory Virtual Address Space File Disk Drive (HDD) Disk Sector (or a block of sectors) Memory Access (it’s an extension of “paging”) CS 314 Operating Systems

File_System/029 Memory-Mapped Files What are the motivations in doing this? We can access any data using a pointer - No need for calling “read” or “write” - No need for preparing “buffer” and buffer copies status = read (fd, buffer, bytes_read); if (status > 0) destination [0] = buffer[0]; destination [0] = my_pointer; - No need for “file descriptor” CS 314 Operating Systems

File_System/030 Memory-Mapped Files How can we use memory-mapped files?  Map a file (to the virtual address space) - OS calls file system and performs “open” - It’s hidden from a user (or application program) - OS performs address boundary check - It’s hidden from a user (or application program) - OS saves updated data in the file - OS calls file system and performs “close”  A user (or application program) can access a file as if it were memory access  Un-map the file CS 314 Operating Systems

File_System/031 Memory-Mapped Files Virtual Address Space (Segment #1) File Disk Drive (HDD) Disk Sector (or a block of sectors) “Segmentation” can be applied to Memory-mapped files Virtual Address Space (Segment #2) 0000 Virtual Address Space (Segment #N)      Segment All segments start at address = 0 CS 314 Operating Systems

File_System/000 CS 314 Operating Systems