Modern Operating Systems - PowerPoint PPT Presentation

Loading...

PPT – Modern Operating Systems PowerPoint presentation | free to download - id: 12f320-MjMxY



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Modern Operating Systems

Description:

each platter. spindle. 4. File System Structure. Hardware. track 0. track n. track 1023. spindle ... Disc allocation usually based on a block or cluster. 1 ... – PowerPoint PPT presentation

Number of Views:90
Avg rating:3.0/5.0
Slides: 37
Provided by: joh133
Learn more at: http://www.scit.wlv.ac.uk
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Modern Operating Systems


1
Modern Operating Systems
  • Lecture 6
  • File Systems

2
File Systems
  • Contents
  • File system requirements
  • Microsoft file systems - FAT and NTFS
  • Read
  • Chapter 11
  • Additional articles accessed via module WEB page.

3
File System StructureHardware
track 0
spindle
track 1023
track n
cylinder 0 top and bottom of each platter
4
File System StructureHardware
sector
track 0
cluster of 4 sectors
spindle
track 1023
track n
Disc allocated in blocks or clusters - 2n
5
File System StructureHardware
  • Disc allocation usually based on a block or
    cluster.
  • 1 block 2n sectors - cluster

6
File System Organisation
  • What does user want from a file system?

7
File System Organisation
  • Usually hierarchical directory structure

link/shortcut
8
Directory Structure
  • Typical directory entries
  • name
  • type
  • dir, exe, link, ...
  • pointer to start of file on device
  • size
  • protection ?????
  • time/date - creation and update

9
File/Directory Operations
  • File access
  • opening, closing
  • sequential access
  • read/write, seek ...
  • direct access
  • read n/write n (n record number)
  • File and directory operations
  • create, delete, rename, search ...

10
Protection
  • Why file protection?
  • Need controlled user access to files/directories.
  • Usually based on user
  • Read/write/execute/delete ...
  • Who can access?
  • Access control lists
  • list of users and type of access allowed for user
  • increases complexity of directory entries
  • access times increase

11
Protection
  • Who can access?
  • User classification (very condensed ACL)
  • universe, group, user
  • usually bit pattern
  • Passwords on files, directories????
  • Processes such as WEB servers run as
  • "nobody" or "system"
  • how can they access users files?

12
Disc Space Allocation
  • Basic requirements
  • Disc space used efficiently
  • Fast access of file content
  • Three basic approaches to allocation of free
    space to files.
  • Contiguous allocation
  • Linked allocation
  • Indexed

13
Disc Space Allocation
  • All rely on allocation of fixed size blocks on
    disc.
  • 1 block 1 sector
  • efficient use of disc free space
  • management of free space becomes inefficient - to
    much time spent in block allocation
  • Solution
  • 1 block 2n sectors - cluster

14
Contiguous Allocation
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
15
Contiguous Allocation
  • Directory points contains number of first block.
  • Block allocation
  • First fit
  • Best fit
  • Worst fit

16
Contiguous Allocation
  • For
  • Fast access of files
  • File stored in contiguous blocks, minimum head
    movement
  • Direct access easy - easy to calculate block
    containing record 'n'
  • Against
  • Have to know size of file before creation
  • Fragmentation
  • compaction required
  • Extending files

17
Linked Allocation
0
1
2
3
4
5
6
7
8
9
14
-1
26
10
11
12
13
14
15
16
17
18
19
-1
8
19
5
20
21
22
23
24
25
26
27
28
29
3
12
file start
work.txt 22
18
Linked Allocation
  • Used by FAT 16/32
  • Directory entry points at first block
  • Pointer in block to next block in file
  • For
  • No fragmentation
  • No prior knowledge of file size needed

19
Linked Allocation
  • Against
  • File can be spread across disc - slow access
  • Direct access slow - why?
  • have to traverse block chain to locate physical
    block containing record 'n'
  • Recovery of file difficult if link lost - power
    failure

20
Indexed Allocation
Block 24 index block
22 3 14 8 26 12 -1 -1 . .
work.txt 24
21
Indexed Allocation
  • Used by UNIX
  • Directory entry points at index block
  • Index block contains pointers to blocks in file
  • For
  • No fragmentation
  • No prior knowledge of file size needed
  • Direct access easy - easy to calculate block
    containing record 'n'

22
Indexed Allocation
  • Against
  • File can be spread across disc - slow access
  • For small files - high wastage of free space -
    why?
  • Small file could be 1 block for data and 1 block
    for index block!
  • File size restricted by size of index block
  • Solution - linked index blocks or multilevel
    indexes

23
Free-Space Management
  • List of all free blocks on disc must be kept.
  • List should be cached
  • Free-space list searched for free block to
    allocate to file.
  • Blocks added to list when file deleted.
  • Should first free block found be allocated to
    file?
  • Two possible approaches are
  • Bit vector/map
  • Linked list

24
Free-Space Management
  • Bit vector/map
  • One bit per block - 1 free, 0 allocated/bad
  • Block no. bits/word ? word bit offset in word
  • Linked list
  • All free blocks on disc linked together in list
  • Ugh! - why?

25
Layered File Systems
application
high level I/O requests
directs request to file system driver
virtual file system
understands directory/file structure
logical file system
maps logical blocks to track/sector
logical device driver
physical device driver
controls device
device
26
Virtual File Systems
User/programmers view
27
Virtual File System
  • Presents generic API to application for different
    file system.
  • What happens when application makes file I/O
    call?
  • O/S examines mount point and determines which
    file system driver to use.
  • Examples - Unix Windows

28
Example - Linux
/dev/hdb1 - ext2
root
home
john
ian
dave
/dev/fd0 - fat
mnt
fat
cdrom
/dev/cdrom - joliet
usr
local
/dev/hdb3 - ext2
src
29
Disc Preparation
  • Four partitions per disc
  • Up to 4 primary
  • Each can contain bootable O/S
  • 1 extended
  • Structure as logical drives which can be
    formatted for different file systems

30
Disc Preparation
  • How is a disc prepared?
  • Create disc partition
  • Format partition - creates empty file system
  • maps of free and allocated space
  • empty directories
  • create bad block table

31
Windows File Systems
  • FAT 16
  • MS-DOS, Win95/98/NT/2000
  • FAT 32
  • Win95 (OSR 2), NT using 3rd party driver, Win2000
  • Windows NT File System (NTFS)
  • Win NT/2000, Win 95 using 3rd party driver

32
FAT 16
  • MS-DOS, Win95/98/NT/2000
  • Partition layout - set of logical sectors
  • 1 logical sector 1 physical sector

33
FAT 16
  • Disc space allocation unit cluster
  • cluster 2n sectors
  • Disc allocation/management variant of linked
    allocation - file allocation table
  • FAT
  • array of cluster numbers
  • one entry per cluster
  • entry 0 - cluster free
  • FAT cached in memory

34
FAT 16
directory entry
85
FFF7
0
0x0000 - free cluster
0xFFF7 - bad cluster
0xFFFF - last cluster
122
83
0x???? - next cluster
0
84
83
85
217
121
FFF8
122
35
FAT 16Limitations?
  • Cluster number 16 bits - problems?
  • Limits number of clusters
  • Limits number of files - gt 1 cluster/file
  • As partition gets bigger so does cluster size
    leading to wasted space in clusters
  • Limited root directory - 512 entries
  • No security - user access
  • No error recovery - extra FAT not used

36
FAT 32
  • Win95 (OSR 2), NT driver, Win2000
  • 32 bit cluster numbers
  • more files
  • smaller clusters - less wasted space
  • bigger partitions
  • No security - user access
  • Root directory ordinary cluster chain - no limit
    on size
  • Limited error recovery
  • can use backup copy of FAT

37
NT Volumes
  • A single drive letter assigned to it, and it is
    formatted for use by a file system. Includes
  • Primary partition
  • Logical drive in an extended partition
  • Volume set
  • Stripe set
  • Mirror set

38
Volume Stripe Sets
  • Volume set - up to 32 multiple areas of free
    space on multiple disks
  • Stripe set
  • NT divides data into blocks (64K)
  • Blocks spread in a fixed order across all disks
    in an array.
  • Enhances performance - simultaneous writes/reads
  • Accessed by fault-tolerant disk driver (FtDisk)

39
Stripe Sets
  • Example - writing a file of 512K in 64K blocks to
    a stripe set on 4 x 1gig discs.
  • Blocks 1-4 written at same time and blocks 5-8
    written at same time.
  • User sees just a 1gig volume.

40
NT Volumes
  • Volume set - made up off up to 32-
  • Multiple areas of free space on multiple disks
  • Stripe set
  • Windows NT and Windows NT Advanced Server disk
    striping (RAID Level 0) creates a disk file
    system called a stripe set by dividing data into
    blocks (64K) and spreading them in a fixed order
    across all disks in an array. By adding data to
    all partitions in the set at the same rate, disk
    striping offers the best performance of all
    Windows NT disk management strategies.
  • Example - writing a file of 512K in 64K blocks to
    a stripe set on 4 discs. Blocks 1-4 written at
    same time and blocks 5-8 written at same time.

41
Mirror Sets
Fault-tolerant disk driver (FtDisk), creates
separate I/O requests for each of the disks
42
Mirror Sets
  • Program issues one read or write
  • Fault-tolerant disk driver (FtDisk), creates
    separate I/O requests for each of the disks.
  • If read failure on one of the disks, FtDisk reads
    the data from the other disk in the mirror set.
  • If there is a write failure on one of the disks
    in the mirror set, FtDisk uses the remaining disk
    for all accesses.

43
NTFS
  • Win NT/2000
  • 64 bit cluster numbers
  • more files
  • smaller clusters - less fragmentation
  • bigger partitions
  • Secure - limiting access to files
  • Recovery - transaction logging

44
Virtual Logical Clusters
  • Volume consists of logical clusters (LCN) 0..N
  • File consists of virtual clusters (VCN) 0..M
  • O/S handles file access in terms of VCNs

45
NTFS
  • What is an NTFS file?
  • Structured object consisting of a collection of
    attributes/value pairs.
  • Attributes include
  • Standard information
  • time stamp, file attributes (read only,
    archive...), hard link count
  • File name - Unicode
  • Security descriptor - owner, who can access it
  • Data

46
NTFS Format
  • All data on volume stored in files
  • directories, allocation bit maps, bootstrap data
    ...
  • Master File Table (MFT) - array of records
  • 1 or more per file, size 1-4kb
  • File records contains
  • Resident attributes (fixed size) - standard info,
    security, file name, data (small file)
  • Pointer to nonresident attributes (variable size)
    - data (larger files), security descriptors, file
    indexes ...

47
MFT record - small file
  • All attributes stored in MFT record - resident
    attributes.

48
MFT record - larger file
  • Resident attributes stored in MFT record.

extent - contiguous run of logical clusters
49
MFT record - larger file
  • A run entry
  • VCN - offset within the attribute's data
  • LCN - location on the disk where the data resides
  • number of contiguous clusters at that position on
    the disk - extent/run
  • Example of run entries
  • VCN LCN No. clusters
  • 0 124 3
  • 3 233 3

50
MFT record - larger file
  • Extra MFT records may be needed for very big
    files or heavily fragmented discs with few
    contiguous clusters.

51
MFT record - small directory
  • All attributes stored in MFT record - resident
    attributes.
  • Attribute - index root - sorted list of files
  • File name, standard information attribute ,file
    reference (MFT record)

attributes
standard information
security descriptor
index root
filename
file1, file2, file3, ...
speeds up file browsing
52
MFT record - large directory
  • Filename entry in index root has optional pointer
    field.
  • Points at index buffer lexicographically less
    than filename

53
NTFS Compression
  • Per file/directory/volume
  • File split into compression units - 16 virtual
    clusters
  • NTFS compresses units
  • if unit lt 15 clusters it is stored compressed
  • else store with no compression

54
NTFS Compression
VCN
0
15
compressed
19
20
21
22
LCN
16
31
compressed
23
24
25
26
27
28
29
30
32
47
not compressed
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
48
63
compressed
113
114
115
116
117
118
119
120
121
122
55
NTFS Compression
  • Run entries
  • Starting Starting Number of
  • VCN LCN clusters
  • 0 19 4
  • 16 23 8
  • 32 97 16
  • 48 113 10
  • Write - each run starts on 16 VC boundary
  • Read - NTFS checks length of run.
  • if less than 16 then compressed

compressed
56
Recovery
  • If NT crashes, file system consistency is
    recovered using a log file.
  • Every transaction that alters volume structure
    recorded in log file.
  • Creation, deletion, extending, truncating,
    renaming, security changes, file info - each will
    require a number of records
  • NOT user data
  • Uses write-ahead logging via the Log File Service
    (LFS).

57
Recovery
  • Log records are written in batches to reduce disc
    activity overheads.
  • Operation
  • (1) NTFS calls LFS to record in cached log file
    any transaction that modifies volume structure.
  • (2) NTFS modifies volume (in cache)
  • (3) LFS causes log file to be flushed to disc
  • (4) Cache manager flushes volume changes to disc

58
Log Record Types
  • Update record
  • Redo information - how apply sub-operation of
    committed transaction to volume (completed)
  • Undo information - how to reverse partially
    committed transaction to volume (did not
    complete)
  • Checkpoint record
  • Written periodically to log - marks successful
    committing of transactions.

59
Recovery
  • NTFS reads log file
  • processes redo records
  • processes undo records

60
Security
  • Security attribute stored in MFT
  • Access token of owner
  • Access control list
About PowerShow.com