Section 10: Device Drivers, FAT, Queuing Theory, Memory Mapped Files

Similar documents
File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

File Systems. CS170 Fall 2018

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

File Management By : Kaushik Vaghani

Preview. Memory Management

CS370 Operating Systems

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

FILE SYSTEMS, PART 2. CS124 Operating Systems Fall , Lecture 24

EECS 482 Introduction to Operating Systems

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

CS3600 SYSTEMS AND NETWORKS

File Layout and Directories

File Systems. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

e-pg Pathshala Subject: Computer Science Paper: Operating Systems Module 35: File Allocation Methods Module No: CS/OS/35 Quadrant 1 e-text

File System Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Midterm Exam #3 Solutions November 30, 2016 CS162 Operating Systems

ECE 650 Systems Programming & Engineering. Spring 2018

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

[537] Fast File System. Tyler Harter

File System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation

Disk Scheduling COMPSCI 386

CS370 Operating Systems

Chapter 5. File and Memory Management

CS 318 Principles of Operating Systems

UNIT III MEMORY MANAGEMENT

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

File System Implementation

File Systems: Fundamentals

COMP 530: Operating Systems File Systems: Fundamentals

Disc Allocation and Disc Arm Scheduling?

File Systems: Fundamentals

Chapter 12: File System Implementation

Optimizing Dynamic Memory Management

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

Frequently asked questions from the previous class survey

Midterm Exam #2 Solutions April 20, 2016 CS162 Operating Systems

CS 318 Principles of Operating Systems

File System Implementation. Sunu Wibirama

File Management. Ezio Bartocci.

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Chapter 12: File System Implementation

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Chapter 4. File Systems. Part 1

CS370 Operating Systems

Chapter 12. File Management

Outlook. File-System Interface Allocation-Methods Free Space Management

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Chapter 6: File Systems

File System. Preview. File Name. File Structure. File Types. File Structure. Three essential requirements for long term information storage

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Lecture 24: Filesystems: FAT, FFS, NTFS

CS 550 Operating Systems Spring File System

Preview. COSC350 System Software, Fall

Chapter 11: Implementing File Systems

Lecture S3: File system data layout, naming

Workloads. CS 537 Lecture 16 File Systems Internals. Goals. Allocation Strategies. Michael Swift

CSC 553 Operating Systems

CSE 4/521 Introduction to Operating Systems. Lecture 23 File System Implementation II (Allocation Methods, Free-Space Management) Summer 2018

CS162 Operating Systems and Systems Programming Lecture 16. I/O Systems. Page 1

Typical File Extensions File Structure

Disks, Memories & Buffer Management

Operating Systems. Operating Systems Professor Sina Meraji U of T

Chapter 11: Implementing File-Systems

Outline. V Computer Systems Organization II (Honors) (Introductory Operating Systems) Advantages of Multi-level Page Tables

CS 111. Operating Systems Peter Reiher

File Directories Associated with any file management system and collection of files is a file directories The directory contains information about

Main Points. File layout Directory layout

File System Internals. Jo, Heeseung

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Midterm II December 4 th, 2006 CS162: Operating Systems and Systems Programming

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

Implementation should be efficient. Provide an abstraction to the user. Abstraction should be useful. Ownership and permissions.

File Systems Ch 4. 1 CS 422 T W Bennet Mississippi College

File Management 1/34

Simple idea 1: load-time linking. Our main questions. Some terminology. Simple idea 2: base + bound register. Protection mechanics.

Chapter 9 Memory Management

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CS 4284 Systems Capstone

COMP 3361: Operating Systems 1 Final Exam Winter 2009

OPERATING SYSTEM. PREPARED BY : DHAVAL R. PATEL Page 1. Q.1 Explain Memory

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Outline. Operating Systems. File Systems. File System Concepts. Example: Unix open() Files: The User s Point of View

I/O and file systems. Dealing with device heterogeneity

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

secondary storage: Secondary Stg Any modern computer system will incorporate (at least) two levels of storage:

File System: Interface and Implmentation

Operating Systems. File Systems. Thomas Ropars.

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Memory Management Topics. CS 537 Lecture 11 Memory. Virtualizing Resources

FILE SYSTEMS, PART 2. CS124 Operating Systems Winter , Lecture 24

File Systems. Information Server 1. Content. Motivation. Motivation. File Systems. File Systems. Files

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Transcription:

Section 10: Device Drivers, FAT, Queuing Theory, Memory Mapped Files CS162 Oct 31st, 2017 Contents 1 Warmup: I/O and Device Drivers 2 2 Vocabulary 2 3 Problems 4 3.1 FAT................................................ 4 3.2 Queuing Theory......................................... 5 3.3 Tying it all together....................................... 6 3.4 Memory Mapped Files...................................... 7 1

1 Warmup: I/O and Device Drivers What is a block device? What is a character device? Why might one interface be more appropriate than the other? Why might you choose to use DMA instead of memory mapped I/O? Give a specific example where one is more appropriate than the other. Explain what is meant by top half and bottom half in the context of device drivers. 2 Vocabulary Simple File System - The disk is treated as a big array. At the beginning of the disk is the Table of Content (TOC) field, followed by data field. Files are stored in data field contiguously, but there can be unused space between files. In the TOC field, there are limited chunks of file description entries, with each entry describing the name, start location and size of a file. Pros and Cons The main advantage of this implementation is simplicity. Whenever there is a new file created, a continuous space on disk is allocated for that file, which makes I/O (read and write) operations much faster. However, this implementation also has many disadvantages. First of all, it has external fragmentation problem. Because only continuous space can be utilized, it may come to the situation that there is enough free space in sum, but none of the continuous space is large enough to hold the whole file. Second, once a file is created, it cannot be easily extended because the space after this file may already be occupied by another file. Third, there is no hierarchy of directories and no notion of file type. External Fragmentation - External fragmentation is the phenomenon in which free storage becomes divided into many small pieces over time. It occurs when an application allocates and deallocates regions of storage of varying sizes, and the allocation algorithm responds by leaving the allocated and deallocated regions interspersed. The result is that although free storage is available, it is effectively unusable because it is divided into pieces that are too small to satisfy the demands of the application. 2

Internal Fragmentation - Internal fragmentation is the space wasted inside of allocated memory blocks because of the restriction on the minimum allowed size of allocated blocks. FAT - In FAT, the disk space is still viewed as an array. The very first field of the disk is the boot sector, which contains essential information to boot the computer. A super block, which is fixed sized and contains the metadata of the file system, sits just after the boot sector. It is immediately followed by a file allocation table (FAT). The last section of the disk space is the data section, consisting of small blocks with size of 4 KiB. In FAT, a file is viewed as a linked list of data blocks. Instead of having a next block pointer in each data block to make up the linked list, FAT stores these pointers in the entries of the file allocation table, so that the data blocks can contain 100% data. There is a 1-to-1 correspondence between FAT entries and data blocks. Each FAT entry stores a data block index. Their meaning is interpreted as: If N > 0, N is the index of next block If N = 0, it means that this is the end of a file If N = 1, it means this block is free Thus, a file can be stored in a non-continuous pattern in FAT. The maximum internal fragmentation equals to 4095 bytes (4K bytes - 1 byte). Directory in the FAT is a file that contains directory entries. The format of directory entries look as follows: Name Attributes Index of 1st block Size Pros and Cons Now we have a review of the pros and cons about FAT. Readers will find most of the following features have been already talked about above. So we only give a very simple list of these features. Pros: no external fragmentation, can grow file size, has hierarchy of directories Cons: no pre-allocation, disk space allocation is not contiguous (accordingly read and write operations will slow), assume File Allocation Table fits in RAM. Otherwise lseek and extending a file would take intolerably long time due to frequent memory operation. Queuing Theory Here are some useful symbols: (both the symbols used in lecture and in the book are listed) µ is the average service rate (jobs per second) T ser or S is the average service time, so T ser = 1 µ λ is the average arrival rate (jobs per second) U or u or ρ is the utilization (fraction from 0 to 1), so U = λ µ = λs T q or W is the average queuing time (aka waiting time) which is how much time a task needs to wait before getting serviced (it does not include the time needed to actually perform the task) T sys or R is the response time, and it s equal to T q + T ser or W + S L q or Q is the average length of the queue, and it s equal to λt q (this is Little s law) 3

3 Problems 3.1 FAT What does it mean to format a FAT file system? Approximately how many bytes of data need to be written in order to format a 2GiB flash drive (with 4KiB blocks and a FAT entry size of 4 bytes) using the FAT file system? Your friend (who has never taken an Operating Systems class) wants to format their external hard drive with the FAT32 file system. The external hard drive will be used to share home videos with your friend s family. Give one reason why FAT32 might be the right choice. Then, give one reason why your friend should consider other options. Explain how an operating system reads a file like D:\My Files\Video.mp4 from a FAT volume (from a software point of view). Compare bitmap-based allocation of blocks on disk with a free block list. 4

3.2 Queuing Theory Explain intuitively why response time is nonlinear with utilization. Draw a plot of utilization (x axis) vs response time (y axis) and label the endpoints on the x axis. If 50 jobs arrive at a system every second and the average response time for any particular job is 100ms, how many jobs are in the system (either queued or being serviced) on average at a particular moment? Which law describes this relationship? Is it better to have N queues, each of which is serviced at the rate of 1 job per second, or 1 queue that is serviced at the rate of N jobs per second? Give reasons to justify your answer. What is the average queueing time for a work queue with 1 server, average arrival rate of λ, average service time S, and squared coefficient of variation of service time C? What does it mean if C = 0? What does it mean if C = 1? 5

3.3 Tying it all together Assume that you have a disk with the following parameters: 1TB in size 6000RPM Data transfer rate of 4MB/s (4 10 6 bytes/sec) Average seek time of 3ms I/O controller with 1ms of controller delay Block size of 4000 bytes What is the average rotational delay? What is the average time it takes to read 1 random block? Assume no queuing delay. Will the actual measured average time to read a block from disk (excluding queuing delay) tend to be lower, equal, or higher than this? Why? Assume that the average I/O operations per second demanded is 50 IOPS. Assume a squared coefficient of variation of C = 1.5. What is the average queuing time and the average queue length? 6

3.4 Memory Mapped Files Memory-mapped files, either as the fundamental way to access files or as an additional feature, is supported by most OS-s. Consider the Unix mmap system call that has the form (somewhat simplified): void mmap(void addr, sizet len, int prot, int flags, int filedes, off t offset); where data is being mapped from the currently open file filedes starting at the position in the file described by offset; len is the size of the part of the file that is being mapped into the process address space; prot describes whether the mapped part of the is readable or writable. The return value, addr, is the address in the process address space of the mapped file region. When the process subsequently references a memory location that has been mapped from the file for the first time, what operations happen in the operating system? What happens upon subsequent accesses? Assume that you have a program that will read sequentially through a very large file, computing some summary operation on all the bytes in the file. Compare the efficiency of performing this task when you are using conventional read system calls versus using mmap. Assume that you have a program that will read randomly from a very large file. Compare the efficiency of performing this task when you are using conventional read and lseek system calls versus using mmap. 7