operating systems {week 16a }

22
Operating Systems {week 16a} Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.

Upload: monet

Post on 24-Feb-2016

63 views

Category:

Documents


0 download

DESCRIPTION

Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D. Operating Systems {week 16a }. Hierarchical storage architecture. very fast. very small. volatile. managed as part of the filesystem. non-volatile. very slow. very large. File management. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Operating Systems {week  16a }

Operating Systems{week 16a}

Rensselaer Polytechnic InstituteCSC 432 – Operating SystemsDavid Goldschmidt, Ph.D.

Page 2: Operating Systems {week  16a }

Hierarchical storage architecture

very small

very large

very fast

very slow

volatile

non-volatile

managed aspart of thefilesystem

Page 3: Operating Systems {week  16a }

File management

A File Management System is a set of OS services that supports files and directories for user applications, OS programs, etc. Data should be organized and

available in a convenient andefficient manner

Files are the basicbuilding blocks

Page 4: Operating Systems {week  16a }

Files A file is an abstraction that represents user

data, OS data, an executable, a device, etc. A file is simply a sequence of bytes

Actual storage location (via network?) andformat are transparent to users

Storage scheme on disk is also transparent▪ Typically involves cylinders, tracks, sectors, etc.

Page 5: Operating Systems {week  16a }

File attributes

File attributes include: Human-readable symbolic name Type (e.g. executable, directory, text, PDF, etc.) Logical location (i.e. containing directory or

path) Physical location on disk Size (in bytes) Protection or security (i.e. permissions) Timestamps (created, last modified, last

accessed)

Page 6: Operating Systems {week  16a }

Pathnames

The pathname (or just path) of a file specifies the sequence of directoriesone must traverse to locatethe file An absolute path starts

at the root node A relative path starts

anywhere

Page 7: Operating Systems {week  16a }

Links

A link provides a shortcut to a file and may circumvent the given directory hierarchy A hard link in Unix is

indistinguishable fromthe original file

A symbolic link in Unixis merely a shortcut

A Windows shortcut is just a symbolic link

Page 8: Operating Systems {week  16a }

Creating and accessing files File creation requires space allocation

Opening a file returns a handle or file descriptor

Read and write operationsuse the handle and anoffset (or file pointer)

The close operation simplydeletes the handle anddeallocates any memory

Page 9: Operating Systems {week  16a }

Deleting files

Deleting a file deallocates all disk spacemarked as in use by the file But likely does not erase file contents Deleted files are recoverable until the

disk space is used for (and overwritten by) other file(s)

The delete operation also removes the corresponding entry in the containing directory

Page 10: Operating Systems {week  16a }

Access methods

An access method describes the mannerand mechanisms by which a process accesses the data in a file

Two common access methods: Sequential access (open, read, write, close) Random access (open, read, write, seek,

close)

Page 11: Operating Systems {week  16a }

Contiguous disk space allocation (i) In a contiguous disk space allocation

scheme, files are allocated to contiguous blocks of disk space

Page 12: Operating Systems {week  16a }

Contiguous disk space allocation (ii) Four files allocated contiguously to disk:

File B outgrows its space and is reallocated:

File D outgrows its space and is reallocated:

Defragmentation combines free disk space:

A A A B B C C C D

A A A C C C D B B B B

A A A C C C B B B B D D

A A A C C C B B B B D D

Page 13: Operating Systems {week  16a }

Clustered disk space allocation (i) In a clustered disk space allocation

scheme, files are allocated to clusters of disk space on an as needed basis

Page 14: Operating Systems {week  16a }

Clustered disk space allocation (ii) Four files allocated contiguously to disk:

File B outgrows its space, so one or more new clusters are allocated:

File D outgrows its space, so one or more new clusters are allocated:

A A A B B C C C D

A A A B B C C C D B B

A A A B B C C C D B B D

Page 15: Operating Systems {week  16a }

Clustered disk space allocation (iii) File accesses may cross cluster

boundaries,causing slower response times

Page 16: Operating Systems {week  16a }

Clustered disk space allocation (iv) Using a linked approach,

each cluster has apointer to the next cluster

Using an indexed approach, a singletable maintains pointers to eachindividual cluster

Page 17: Operating Systems {week  16a }

Managing free space

Managing free blocks (or free clusters) may follow the same scheme as for a single file Linked scheme Indexed approach

Bitmapped approach: A bitmap is maintained in memory Each bit corresponds to a block or cluster A 0 indicates a free block A 1 indicates the block is in use

Page 18: Operating Systems {week  16a }

File allocation table (i)

A file allocation table (FAT) maps logical filesto their physical addresses on a disk A pure FAT would have an entry

for each sector (e.g. 512 bytes) To improve performance, clusters

of contiguous sectors are used Clusters range from 4 to 64 sectors

(e.g. 2,048 to 32,768 bytes)

Page 19: Operating Systems {week  16a }

File allocation table (ii)

Microsoft FAT-32 filesystem maps to clusters May require linked clusters to house

entire FAT

Page 20: Operating Systems {week  16a }

Linux ext2 and ext3

Linux uses indexed clusters

Page 21: Operating Systems {week  16a }

Unix inodes (i)

In Unix, file information is stored in an index node (I-node), which contains: Mode and type of file Number of links to the file File owner’s userid and groupid Size of file (in bytes) Last access and last modified times Number of blocks allocated to the file Pointers to the first twelve blocks Pointers to three additional blocks of

pointers

Page 22: Operating Systems {week  16a }

Unix inodes (ii)inode12

1024

10242

10243

clustercluster

cluster

cluster

cluster

cluster

inode1024

single indirect

inode1024

double indirectinode1024

inode1024

… …

inode10242

triple indirect