Disk Scheduling COMPSCI 386

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

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

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

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

Chapter 10: Mass-Storage Systems

Operating Systems. Operating Systems Professor Sina Meraji U of T

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

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

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

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

CS3600 SYSTEMS AND NETWORKS

V. Mass Storage Systems

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

EECS 482 Introduction to Operating Systems

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

CSE 451: Operating Systems Spring Module 12 Secondary Storage

Mass-Storage Structure

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

STORAGE SYSTEMS. Operating Systems 2015 Spring by Euiseong Seo

CS420: Operating Systems. Mass Storage Structure

Chapter 13: Mass-Storage Systems. Disk Scheduling. Disk Scheduling (Cont.) Disk Structure FCFS. Moving-Head Disk Mechanism

Chapter 13: Mass-Storage Systems. Disk Structure

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CHAPTER 12: MASS-STORAGE SYSTEMS (A) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 10: Mass-Storage Systems

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

Department of Computer Engineering University of California at Santa Cruz. File Systems. Hai Tao

I/O, Disks, and RAID Yi Shi Fall Xi an Jiaotong University

CSE 451: Operating Systems Winter Secondary Storage. Steve Gribble. Secondary storage

Mass-Storage Structure

CS370 Operating Systems

Chapter 11. I/O Management and Disk Scheduling

Principles of Operating Systems CS 446/646

CSE 451: Operating Systems Winter Lecture 12 Secondary Storage. Steve Gribble 323B Sieg Hall.

Anatomy of a disk. Stack of magnetic platters. Disk arm assembly

22 File Structure, Disk Scheduling

Disks, Memories & Buffer Management

Chapter 12: Mass-Storage

Silberschatz, et al. Topics based on Chapter 13

CS510 Operating System Foundations. Jonathan Walpole

Secondary storage. CS 537 Lecture 11 Secondary Storage. Disk trends. Another trip down memory lane

Hard Disk Drives. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

19 File Structure, Disk Scheduling

Disc Allocation and Disc Arm Scheduling?

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 420, York College. November 21, 2006

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems Fall 2018

File Systems: Fundamentals

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

File Systems: Fundamentals

CSE 451: Operating Systems Spring Module 12 Secondary Storage. Steve Gribble

Disks and RAID. CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, E. Sirer, R. Van Renesse]

Final Exam Preparation Questions

COMP 530: Operating Systems File Systems: Fundamentals

u Covered: l Management of CPU & concurrency l Management of main memory & virtual memory u Currently --- Management of I/O devices

COS 318: Operating Systems. Storage Devices. Jaswinder Pal Singh Computer Science Department Princeton University

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

CSC369 Lecture 9. Larry Zhang, November 16, 2015

Chapter 12: Mass-Storage

Lecture 16: Storage Devices

Lecture S3: File system data layout, naming

Chapter 12: Mass-Storage

EECS 482 Introduction to Operating Systems

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

COS 318: Operating Systems. Storage Devices. Kai Li Computer Science Department Princeton University

I/O & Storage. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

CS 537 Fall 2017 Review Session

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

Disk scheduling Disk reliability Tertiary storage Swap space management Linux swap space management

Chapter 12: Secondary-Storage Structure. Operating System Concepts 8 th Edition,

Chapter 12: Mass-Storage Systems. Operating System Concepts 8 th Edition,

File System Internals. Jo, Heeseung

Operating Systems 2010/2011

Fall COMP3511 Review

Module 13: Secondary-Storage Structure

ECE 650 Systems Programming & Engineering. 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

I/O CANNOT BE IGNORED

Disk Scheduling. Based on the slides supporting the text

COS 318: Operating Systems. Storage Devices. Vivek Pai Computer Science Department Princeton University

Chapter 14: Mass-Storage Systems. Disk Structure

Operating Systems Design Exam 2 Review: Spring 2011

I/O and file systems. Dealing with device heterogeneity

Operating Systems. Week 9 Recitation: Exam 2 Preview Review of Exam 2, Spring Paul Krzyzanowski. Rutgers University.

CS 416: Opera-ng Systems Design March 23, 2012

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

Block Device Driver. Pradipta De

Operating Systems. File Systems. Thomas Ropars.

Chapter 14: Mass-Storage Systems

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

CS370 Operating Systems

Operating Systems (1DT020 & 1TT802) Lecture 11. File system Interface (cont d), Disk Management, File System Implementation.

Mass-Storage Systems

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

MODULE 4. FILE SYSTEM AND SECONDARY STORAGE

Chapter 12: File System Implementation

Introduction to I/O and Disk Management

Transcription:

Disk Scheduling COMPSCI 386

Topics Disk Structure (9.1 9.2) Disk Scheduling (9.4) Allocation Methods (11.4) Free Space Management (11.5)

Hard Disk Platter diameter ranges from 1.8 to 3.5 inches. Both sides coated with magnetic material. A motor spins the platters at 5000 15000 RPMs. A read/write head floats above each platter on thin cushion of air (measured in microns). Heads connected to a disk arm that moves the heads as a unit.

Hard Disk Surface of a platter is logically divided into concentric tracks. Tracks subdivided into sectors. The set of tracks at one arm position forms a cylinder. 1000s of cylinders. 100s of sectors per track. Storage measured in GBs.

Hard Disk The transfer rate is the rate at which data flows between the drive and the computer. Random access time: seek time (disk arm moves to target cylinder). rotational latency (target sector rotates into position under the head).

Hard Disk OS places a command into host controller via memory-mapped I/O ports. Host controller communicates with disk controller built into the disk drive. Data transferred between disk controller cache and the surface of the disk.

Solid-State Disks Non-volatile memory used as a hard drive. No moving parts. consume less power more reliable and faster resistant to shock and vibration resistant to environmental conditions More expensive: 23 vs 3 per GB Sometimes used as cache for HDD. Disk scheduling algorithms do not apply.

Disk Structure HDDs addressed as linear arrays of logical blocks. Logical block size is usually 512 bytes. Array is mapped sequentially onto sectors. Sector 0 is 1st sector on 1st track on outermost cylinder. The mapping proceeds in order through the track, then through the remaining tracks in that cylinder, and then through the other cylinders (moving inward). In principle, it is easy to map logical disk block to physical (cylinder, track, sector) address, but...

Disk Structure Some disks have damaged sectors. Hidden by the mapping through the use of spare sectors elsewhere. The number of sectors per track may not be constant. With constant linear velocity media, the density of bits per track is uniform. The farther a track is from the center, the greater its length, so more sectors per track. The disk spins faster as the heads move toward the inner tracks in order to maintain constant data transfer rate. With constant angular velocity, rotation speed is fixed and the density of bits decreases from inner to outer tracks so that the data transfer rate remains constant.

Disk Scheduling Bandwidth: total number of bytes transferred divided by the total time between the first request for service and the completion of the last request. When a process needs to read/write from/to disk, it makes a system call specifying: input or output? disk address for the transfer memory address for the transfer total number of sectors to be transferred If the drive is busy, the request will be queued. How is the queue to be serviced?

Disk Scheduling Suppose the queue has requests for I/O to blocks on cylinders 98, 183, 37, 122, 14, 124, 65, 67. FCFS SSTF (shortest seek time first); starvation? SCAN (elevator algorithm) C-SCAN When the head reaches one end of the disk and reverses direction, the greatest density of requests will be at the other end (since it has just traversed the near end). LOOK AND C-LOOK

Disk Scheduling FCFS SCAN SSTF C-SCAN

Caveat It seems that empirical studies of the performance of disk scheduling algorithms done in the 1970s often relied on an invalid assumption: The seek time to service a request is proportional to the distance travelled by the disk arm. Can you guess why this assumption is invalid?

Caveat It seems that empirical studies of the performance of disk scheduling algorithms done in the 1970s often relied on an invalid assumption: The seek time to service a request is proportional to the distance travelled by the disk arm. Can you guess why this assumption is invalid? The arm does not move at constant velocity. It must accelerate to full speed and decelerate to stop. Elementary physics: d = ½a t 2

Caveat Suppose disk arm accelerates at constant rate for the first half of a seek, then decelerates at the same rate for the second half. Assume the disk can perform a seek to an adjacent cylinder in 1 ms and a seek over all 5000 cylinders in 18 ms. Can we write an equation for the seek time as a function of the seek distance?

Caveat Equation should have the form t = x + y sqrt(l), where L is the seek distance in cylinders. Solve simultaneous equations from (t = 1, L = 1) and (t = 18, L = 4999). t = 0.7561 + 0.2439 sqrt(l) Performance of disk scheduling algorithms should really be analysed in terms of seek times, not seek distances.

Explain Solid state disks often use FCFS disk scheduling. FCFS is fair, unlike SSTF, SCAN, and C-SCAN. The OS must sometimes be unfair. Paging and swapping take priority over user process I/O. Kernel-initiated I/O (e.g., writing file system metadata) may need to take priority over user process I/O requests. Kernel may support real-time process priorities.

Explain There are 5000 cylinders numbered 0-4999. Drive is currently serving request at cylinder 2150. Previous request was at cylinder 1805. The queue of pending requests in FIFO order is 2069, 1212, 2296, 2800, 544, 1618, 356, 1523, 4965, 3681. Calculate the total distance (in cylinders) traversed by the disk arm to satisfy all pending requests using FCFS, SSTF, SCAN, LOOK, C-SCAN, C-LOOK

Project Compare performance of SCAN and C-SCAN scheduling with uniform distribution of requests. Evaluate in terms of the average response time, variance of response times, and effective bandwidth. Why would there be a difference in variance? SCAN favors request near the middle cylinders.

Question (Part 1) Requests are not usually uniformly distributed. For example, a cylinder with file-system metadata will probably be accessed much more frequently than cylinders containing only files. Suppose 50% of requests are for a small, fixed set of cylinders. Would any of the scheduling algorithms we considered be good for this case?

Question (Part 1) Requests are not usually uniformly distributed. For example, a cylinder with file-system metadata will probably be accessed much more frequently than cylinders containing only files. Suppose 50% of requests are for a small, fixed set of cylinders. Would any of the scheduling algorithms we considered be good for this case? SSTF would take greatest advantage of this situation. FCFS would suffer if requests for high-demand cylinders were interspersed with request for those far away.

Question (Part 2) Propose a disk scheduling algorithm that gives even better performance by taking advantage of the hot spot on the disk.

Question (Part 2) Propose a disk scheduling algorithm that gives even better performance by taking advantage of the hot spot on the disk. Place hot data near the middle of the disk. Modify SSTF to prevent starvation. If disk is idle for more than 50 ms, do an anticipatory seek to the hot spot.

Allocation Methods How should space be allocated for files so that access is fast and disk space is utilized efficiently? Contiguous Linked Indexed

Contiguous Allocation Simple and fast (for sequential and random access). Up against the dynamic storage-allocation problem. First fit and best fit are better than worst fit in terms of time and storage utilization. Neither first fit nor best fit is particularly good in terms of storage utilization, but first fit is faster.

Contiguous Allocation Big problem: external fragmentation, just as with contiguous memory allocation. Compaction can be done on-line, but performance penalty is significant, especially for large disks. Another problem: how much space needed for file? Even if total amount of needed space were known, preallocation can be wasteful (file grows slowly).

Linked Allocation Each file is a linked list of disk blocks. A directory contains a pointer to first and last blocks of a file. No external fragmentation and size of file need not be declared when file is created.

Linked Allocation Effective only for sequential access of files. If a pointer requires 4 bytes from a 512-byte block, 0.78% of the disk is being used just for pointers. The usual solution is to allocate clusters, which improves disk throughput (fewer head seeks) and decreases pointer storage overhead. Drawback: internal fragmentation.

Linked Allocation Reliability is also a problem. If a pointer is corrupted by an OS bug or a hardware failure, then an I/O operation on the file might lead into the free space or into another file.

Linked Allocation A File Allocation Table (FAT) is a variant of linked allocation that was used by MS DOS. A section of disk set aside to contain a table whose indices correspond to disk blocks. Basically, it s a linked list embedded in an array. An unused block indicated by zero entry in table. Efficient for random access. But there are many seeks since table must be consulted for each request; table must be cached in memory.

Indexed Allocation All pointers stored in one location. Each file has its own index block, an array of disk block addresses. Random access without external fragmentation. Pointer overhead greater than for linked allocation. UNIX systems keep the first few pointers of an index block in the file s inode; some point to direct blocks, some to indirect blocks.

Indexed Allocation All pointers stored in one location. Each file has its own index block, an array of disk block addresses. Random access without external fragmentation. Pointer overhead greater than for linked allocation. UNIX systems keep the first few pointers of an index block in the file s inode; some point to direct blocks, some to indirect blocks.

Indexed Allocation Pointer overhead greater than for linked allocation.

Free Space Management The OS must keep track of disk blocks not yet allocated to a file or directory. To create a file, the free-space list must be searched for a block of adequate size. How to implement free-space list? bit map linked list grouping counting space maps

Bitmap Suppose blocks 2, 3, 5, 8, 13, and 21 are free. 0011010010000100000001 Using machine instructions for bit manipulation, is it simple and efficient to find the first free block or the first sequence of n free blocks. Interpret bitmap as a sequence of words and check each on in sequence for inequality with zero. Block number: (bits per word) * (number of zero-valued words) + (offset of first 1 in first non-zero-valued word)

Bitmap Inefficient unless kept in main memory. Feasible in main memory only for small disks. 1 TB disk with 4KB blocks = 32 MB bitmap. 240 / 212 = 228 bits = 225 bytes = 32 * 220 bytes = 32 MB And disk size is constantly increasing.

Linked List A pointer to the first free block is stored in a special location on disk and cached in memory. Traversing linked list to find sufficient storage for a file is not efficient, but this does not happen often; usually the OS just needs one more block to allocate to a file.

Grouping Modification of linked-list approach. First free block stores the addresses of n free blocks, the last of which stores addresses of n free blocks,... Addresses of large number of free blocks can be obtained quickly.

Counting Motivating idea: several contiguous blocks may be allocated or freed at one time. Store address of the first free block and the number of contiguous free blocks following it. Each entry in the free-space list contains a disk address and a count. Each entry requires more space, but there will be fewer (probably) entries. Entries can be stored as a balanced tree for fast insertion, deletion, and lookup.

Self-Balancing Trees Search Trees AVL trees Red-Black trees Splay trees Multiway Search Trees (2, 4) Trees External Search Trees (optimized for reading and writing large blocks) B trees B+ trees

2-4 Trees Size property: each internal node has 2, 3, or 4 children Depth property: each leaf has the same depth. O(log n) time to search, insert, or delete. 12 5, 10 3, 4 6, 7, 8 15 11 13, 14 17 Convenient to assume keys stored at internal nodes and leaves are merely placeholders.

Space Maps Oracle s ZFS file system designed to handle massive numbers of files, directories, and file systems. File systems can be arranged hierarchically. Freeing 1 GB of data on a 1 TB disk could cause changes to thousands of blocks of bitmap. ZFS uses a combination of simple and sophisticated techniques (including structures called space maps). Details omitted...