CS 2200 - PowerPoint PPT Presentation

1 / 41
About This Presentation
Title:

CS 2200

Description:

Reverse and continue scanning. Lower variance than SSTF, similar mean waiting time ... Same as SCAN but reverse direction if no more requests in the scan direction ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 42
Provided by: BillL161
Category:
Tags: scan

less

Transcript and Presenter's Notes

Title: CS 2200


1
CS 2200
  • Storage and File Systems

2
Review...
  • Disk drive has one or more platters
  • Platters spinning constantly
  • Heads move in and out

3
Review...
  • Radial position is called a track on one surface.
    All tracks on all surfaces cylinder
  • Tracks divided into sectors
  • Must move head to correct position (seek)
  • Must wait for platter to rotate under head
  • Rotational Latency

4
Disk Scheduling
  • Algorithm Objective
  • Minimize seek time
  • Assumptions
  • Single disk module
  • Requests for equal sized blocks
  • Random distribution of locations on disk
  • One movable arm
  • Seek time proportional to tracks crossed
  • No delay due to controller
  • Read/write times are equal

5
Disk Scheduling
  • Measures of response
  • Mean wait time
  • Variance of wait time
  • Throughput
  • Measures of load
  • Number of requests per second
  • Average queue length

6
Policies
  • FCFS
  • Fair
  • OK for small loads, saturated quickly
  • High mean wait time
  • Low variance
  • Leads to wide swings in seeks leading to high
    mean wait time

7
FCFS Demo
  • Start Track 5
  • Queue 11 16 4 12 1 13 6 7

8
FCFS
9
Policies
  • SSTF (Shortest seek time first)
  • Analogous to SJF for CPU scheduling
  • Good throughput
  • Saturates slowest
  • High variance
  • Possibility of starvation

10
SSTF Demo
  • Start Track 5
  • Queue 11 16 4 12 1 13 6 7
  • 6 7 4 1 11 12 13 16

11
SSTF
12
Policies
  • SCAN (elevator algorithm)
  • Start at one end, move toward the other end
  • Service requests on the way
  • Reverse and continue scanning
  • Lower variance than SSTF, similar mean waiting
    time
  • Requests just in front versus behind the
    direction of head motion?

13
SCAN Demo
  • Start Track 5
  • Queue 11 16 4 12 1 13 6 7
  • 4 1 0 6 7 11 12 13 16 18

14
SCAN
15
Policies
  • C-SCAN
  • Treat disk as if it were circular
  • Scan in one direction, retract, and resume scan
  • Leads to more uniform waiting time than SCAN

16
C-SCAN Demo
  • Start Track 5
  • Queue 11 16 4 12 1 13 6 7
  • 6 7 11 12 13 16 18 0 1 4

17
C-Scan
18
Policies
  • Look
  • Same as SCAN but reverse direction if no more
    requests in the scan direction
  • Leads to better performance than SCAN
  • C-Look
  • Circular look

19
C-LOOK Demo
  • Start Track 5
  • Queue 11 16 4 12 1 13 6 7
  • 6 7 11 12 13 16 1 4

20
C-Look
21
Policies
  • N-Step SCAN
  • Two queues
  • active (N requests or less)
  • latent
  • Service active queue
  • When no more in active, transfer N requests from
    latent to active
  • Leads to lower variance compared to SCAN
  • Worse than SCAN for mean waiting time

22
Algorithm Selection
  • SSTF (Shortest Seek Time First) is common. Better
    than FCFS.
  • If load is heavy SCAN and C-SCAN best because
    less likely to have starvation problems
  • We could calculate an optimum for any series of
    requests but costly
  • Depends on number type of requests
  • e.g. Imagine we only have one request pending
  • Also depends on file layout
  • Recommend a modular scheduling algorithm that can
    be changed.

23
Questions?
24
Typical Question
  • Suppose a disk drive has 5000 cylinders, numbered
    from 0 to 4999. Currently at cylinder 143 and
    previous request was at 125. Queue (in FIFO
    order) is
  • 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130
  • Starting from current position what is total
    distance moved (in cyclinders) the disk head
    moves to satisfy all requests
  • Using FCFS, SSTF, SCAN, LOOK, C-SCAN

25
FCFS
  • 143 - 86 57
  • 86 - 1470 1384
  • 1470 - 913 557
  • 913 - 1774 861
  • 1774 - 948 826
  • 948 - 1509 561
  • 1509 - 1022 487
  • 1022 - 1750 728
  • 1750 - 130 1620
  • 7081 Cylinderslt-- Answer

26
Typical Question
  • "Currently at cylinder 143 and previous request
    was at 125."
  • For which of these algorithms do we NOT need to
    know that the previous request was at 125
  • SSTF
  • SCAN
  • LOOK
  • C-SCAN

27
Questions?
28
Buffering
  • Buffer is a memory area that stores data while
    transferred between two devices or one device and
    an application.
  • Why?

29
Buffering
  • Deal with speed mismatch of producer and consumer
  • Modem to disk
  • Adapt between devices which have different
    data-transfer sizes.
  • Hard disk to floppy disk
  • Deal with copy semantics
  • Application makes syscall requesting write
  • Supplies address and number of bytes
  • What happens if application changes data?

30
I/O Buffer Management
  • User or OS?
  • User
  • Pros
  • Avoid extra copying
  • Application has better control since it knows
    number and size of I/O buffers
  • Cons
  • Complexity to application software
  • OS more appropriate for global resource
    management
  • OS may be able to avoid copying by locking pages
    in memory

31
User Buffer
Buffer
User Area
Can lock pages
32
OS Buffer
Buffer
Buffer
User Area
OS Area
33
Questions?
34
Storage Abstraction
  • Process is the OS abstraction for processor
  • Data structures are the language abstraction for
    memory
  • Consider a program
  • Text, and data structures are meaningful for the
    life of the program (i.e. when it is executing as
    a process)
  • What about state that a program wants to leave
    behind after execution as a process terminates?
  • Magnetic/optical store on the hardware side
  • An abstraction of this hardware presented by the
    OS

35
Device independent I/O
  • What abstraction should the OS provide?
  • Virtual devices with generic API
  • open, seek, read, write, close
  • Advantages
  • programming API is device independent
  • easy to add new devices
  • Step towards such a device independent I/O
  • File systems...

36
File System
  • File A Collection of info with attributes
  • Data (the actual user info)
  • Attributes name, access rights, physical
    representation, logical representation,
    accounting info,
  • Where are the attributes?
  • Can be part of the file, and/or
  • Physical representation kept in directory

37
  • File names
  • Single level (Univac EXEC 8, circa late 1970s,
    DEC RT-11)
  • Unique name for each filerestrictive
  • Single directory to searchexpensive
  • Two-level (DEC TOPS-10, RSX-11M circa early 80s)
  • Top level user/project
  • Directory tells how to get to an individual
    user/project
  • Example dp033,077test.dat
  • Directory was named dp0,0033077.dir
  • Second level file name unique to user/project

38
  • File names
  • Hierarchical (Multics, Unix, NT)
  • A file name made of several parts
    (/users/l/leahy/foo)
  • Each part unique with respect to previous parts
  • Directory?
  • Just another file that contains info about files
    at next lower levels

39
  • Other naming issues
  • Aliases
  • What is common and what is distinct?
  • Data? Attributes?
  • Deletion of a file?
  • Recursive aliases
  • File name extensions
  • Mandatory (TOPS 10)
  • Optional (Unix, NT)
  • Version numbers
  • Write implicitly creates new versions.
  • (RSX-11M)
  • Purging
  • Write over-writes previous version (Unix, NT)

40
Access Rights
  • Permissions on a file
  • Read, write, execute, delete, change permissions
  • Change permissions
  • Who can?
  • Who should?
  • Storing access rights
  • One per user per file feasible?

41
Physical Representation of File
  • Goals
  • Fast sequential access (SA)
  • Fast random access (RA)
  • Ability to grow the file
  • Easy allocation of storage
  • Data structure in the file system
  • A table that maps file name to disk address
  • Free list of disk blocks

42
Allocation Strategies
  • 1. Fixed contiguous regions
  • Regions
  • One track
  • One cylinder
  • Contiguous range of cylinders
  • Characteristics
  • Data structures (on the disk at a well-known
    place)
  • Free list bit map of free cylinders
  • Directory mapping table (file name to cylinder
    address)
  • SA and RA quick allocation is quick as well
  • Cannot grow file size above allocation
  • DEC RT-11

-(
43
Allocation Strategies
  • 2. Contiguous regions with overflow areas
  • Secondary area for growth (also contiguous)
  • Characteristics
  • RA requires some computation
  • SA as fast as 1.

44
Allocation Strategies
  • 3. Linked allocation
  • File divided into (sector sized) blocks
  • Each block points to next one disk becomes a
    giant linked list!
  • Characteristics
  • Data structures (on the disk at a well-known
    place)
  • free-list (a linked list) mapping table (file
    name to starting disk block)
  • SA slow due to seek time RA pointer chasing
  • Growth easy allocation is expensive

45
Allocation Strategies
  • 4. File Allocation Table (FAT) MS-DOS
  • At the beginning of each partition, a table that
    contains one entry for each disk block in that
    partition (0 indicates it is free)
  • A file occupies a number of entries in the FAT
  • Each entry points to the next entry in the FAT
    for SA (-1 indicates it is the last block)
  • Characteristics
  • FAT is the data structure efficient for
    allocation less chance of screwing up as in (3)
  • SA requires FAT lookup (can be alleviated by
    caching the FAT)
  • RA requires some computation
  • Limit on size of partition (this is BAD!) growth
    easy

46
Allocation Strategies
  • 5. Indexed Allocation
  • File represented by an index block (on the disk),
    a table of disk blocks for the file
  • Characteristics
  • Data structures
  • Mapping table (file name to index block)
  • Free list (can be a bit map of available disk
    blocks)
  • Limit on the size of the file
  • Wasted space
  • Could have mechanism for additional index blocks
  • OR...

47
Allocation Strategies
  • 6. Multilevel Indexed Allocation
  • File represented by an index block (on the disk),
    an indirection table of disk blocks for that file
  • One level indirection
  • Two level indirection
  • Triple indirection

48
Multilevel Indexed Allocation
49
Allocation Strategies
  • 7. Hybrid (BSD Unix)
  • Combination of (5) and (6)
  • Each file represented by an i-node (index node)
  • Index to first n disk blocks, plus
  • A single indirect index, a double indirect index,
    a triple indirect index
  • Characteristics
  • SA requires i-node reference
  • overhead reduced by in-memory cache
  • RA requires some computation but much quicker
    than (3)
  • Growth is easy
  • Allocation overhead same as (3)

50
Unix Inode
51
Logical Representation
  • FS may treat a file as an un-interpreted stream
    of bytes (Unix approach)
  • Structured files of a user-defined record (not in
    Unix or NT)
  • Only feasible if FS implemented at user level
  • What happens when you edit a file?
  • Growth of a file is it always at the end of the
    file?
  • How does the storage system handle insertions in
    the middle of a file?

52
Robustness
  • How to handle machine crashes?
  • Duplicate critical blocks (i-nodes) on disk
  • Check for agreement on restart (fsck in Unix)
  • On write
  • Prepare new blocks on disk
  • Prepare intention to change i-node on disk
  • Change i-node on the disk
  • Get rid of intention list from disk
  • Backup on tape system

53
Questions?
Write a Comment
User Comments (0)
About PowerShow.com