0% found this document useful (0 votes)
9 views60 pages

FULL PPT-Unit 5

The document outlines Unit V of an Operating Systems course, focusing on storage structures including mass storage, disk scheduling, and file management. It covers various disk technologies, scheduling algorithms, RAID structures, and file concepts, detailing how operating systems manage disk space and file operations. Additionally, it discusses directory structures and file sharing in multi-user systems, highlighting the importance of efficient data management in operating systems.

Uploaded by

klreddy9010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views60 pages

FULL PPT-Unit 5

The document outlines Unit V of an Operating Systems course, focusing on storage structures including mass storage, disk scheduling, and file management. It covers various disk technologies, scheduling algorithms, RAID structures, and file concepts, detailing how operating systems manage disk space and file operations. Additionally, it discusses directory structures and file sharing in multi-user systems, highlighting the importance of efficient data management in operating systems.

Uploaded by

klreddy9010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 60

Department of

Computer Science and Design

10213CD103 –OPERTATING SYSTEMS

Faculty
Name :Dr.K.Udayakumar
Employee Id : TTS3804
Slot Number : S4/S10
Unit No :V
UNIT V STORAGE STRUCTURE

06/17/25 2
Course Content

UNIT V STORAGE STRUCTURE


 Mass Storage Structure: Disk Structure
 Disk Scheduling
 Disk Management
 File
 System Interface: File Concepts
 Directory Structure
 File Sharing
 Protection
 File System
 Case Study: Linux operating system
06/17/25 Department of Computer Science and Engineering 3
Mass Storage Structure

• Magnetic disks provide bulk of secondary storage of modern computers


• Drives rotate at 60 to 250 times per second
• Transfer rate is rate at which data flow between drive and computer
• Positioning time (random-access time) is time to move disk arm to desired
cylinder (seek time) and time for desired sector to rotate under the disk head
(rotational latency)
• Head crash results from disk head making contact with the disk surface.
• Disks can be removable
• Drive attached to computer via I/O bus
• Busses vary, including EIDE, ATA, SATA, USB, Fibre Channel, SCSI, SAS,
Firewire
• Host controller in computer uses bus to talk to disk controller built into drive
or storage array

Department of Computer Science and Engineering


06/17/25 4
Moving-head Disk Mechanism

Department of Computer Science and Engineering


06/17/25
Solid-State Disks

• Nonvolatile memory used like a hard drive


• Many technology variations
• Can be more reliable than HDDs
• More expensive per MB
• Maybe have shorter life span
• Less capacity
• But much faster
• Busses can be too slow -> connect directly to PCI for example
• No moving parts, so no seek time or rotational latency

Department of Computer Science and Engineering


06/17/25
Disk Scheduling

Department of Computer Science and Engineering


Disk Scheduling

Department of Computer Science and Engineering


Disk Scheduling

• The operating system is responsible for using hardware efficiently — for


the disk drives, this means having a fast access time and disk bandwidth

• Minimize seek time

• Seek time  seek distance

• Disk bandwidth is the total number of bytes transferred, divided by the


total time between the first request for service and the completion of the
last transfer

Department of Computer Science and Engineering


Disk Scheduling

• Note that drive controllers have small buffers and can manage a queue of
I/O requests (of varying “depth”)

• Several algorithms exist to schedule the servicing of disk I/O requests

• The analysis is true for one or many platters

• We illustrate scheduling algorithms with a request queue (0-199)

98, 183, 37, 122, 14, 124, 65, 67

Head pointer 53

Department of Computer Science and Engineering


FCFS

Illustration shows total head movement of 640 cylinders

Department of Computer Science and Engineering


SSTF
• Shortest Seek Time First selects the request with the minimum seek time from
the current head position
• SSTF scheduling is a form of SJF scheduling; may cause starvation of some
requests
• Illustration shows total head movement of 236 cylinders

Department of Computer Science and Engineering


SCAN

• The disk arm starts at one end of the disk, and moves toward the other
end, servicing requests until it gets to the other end of the disk, where the
head movement is reversed and servicing continues.

• SCAN algorithm Sometimes called the elevator algorithm

• Illustration shows total head movement of 236 cylinders

• But note that if requests are uniformly dense, largest density at other end
of disk and those wait the longest

Department of Computer Science and Engineering


SCAN

Department of Computer Science and Engineering


C-SCAN

• Provides a more uniform wait time than SCAN

• The head moves from one end of the disk to the other, servicing requests
as it goes
• When it reaches the other end, however, it immediately returns to the
beginning of the disk, without servicing any requests on the return trip

• Treats the cylinders as a circular list that wraps around from the last
cylinder to the first one

• Total number of cylinders?

Department of Computer Science and Engineering


C-SCAN

Department of Computer Science and Engineering


C-LOOK

• LOOK a version of SCAN, C-LOOK a version of C-SCAN

• Arm only goes as far as the last request in each direction, then reverses
direction immediately, without first going all the way to the end of the
disk

• Total number of cylinders?

Department of Computer Science and Engineering


C-LOOK

Department of Computer Science and Engineering


Selecting a Disk-Scheduling Algorithm

• SSTF is common and has a natural appeal


• SCAN and C-SCAN perform better for systems that place a heavy load on the disk
• Less starvation
• Performance depends on the number and types of requests
• Requests for disk service can be influenced by the file-allocation method
• And metadata layout
• The disk-scheduling algorithm should be written as a separate module of the operating
system, allowing it to be replaced with a different algorithm if necessary
• Either SSTF or LOOK is a reasonable choice for the default algorithm
• What about rotational latency?
• Difficult for OS to calculate
• How does disk-based queueing effect OS queue ordering efforts?

Department of Computer Science and Engineering


Disk Management

• Low-level formatting, or physical formatting — Dividing a disk into


sectors that the disk controller can read and write
• Each sector can hold header information, plus data, plus error
correction code (ECC)
• Usually 512 bytes of data but can be selectable
• To use a disk to hold files, the operating system still needs to record its own
data structures on the disk
• Partition the disk into one or more groups of cylinders, each treated as
a logical disk
• Logical formatting or “making a file system”
• To increase efficiency most file systems group blocks into clusters
• Disk I/O done in blocks
• File I/O done in clusters

Department of Computer Science and Engineering


Disk Management

• Raw disk access for apps that want to do their own block management,
keep OS out of the way (databases for example)

• Boot block initializes system

• The bootstrap is stored in ROM

• Bootstrap loader program stored in boot blocks of boot partition

• Methods such as sector sparing used to handle bad blocks

Department of Computer Science and Engineering


Booting from a Disk in Windows

Department of Computer Science and Engineering


Swap-Space Management

• Swap-space — Virtual memory uses disk space as an extension of main


memory
• Less common now due to memory capacity increases
• Swap-space can be carved out of the normal file system, or, more commonly, it
can be in a separate disk partition (raw)
• Swap-space management
• 4.3BSD allocates swap space when process starts; holds text segment (the
program) and data segment
• Kernel uses swap maps to track swap-space use

Department of Computer Science and Engineering


Swap-Space Management
• Solaris 2 allocates swap space only when a dirty page is forced out of
physical memory, not when the virtual memory page is first created
• File data written to swap space until write to file system requested
• Other dirty pages go to swap space due to no other home
• Text segment pages thrown out and reread from the file system as
needed
• What if a system runs out of swap space?
• Some systems allow multiple swap spaces

Department of Computer Science and Engineering


Data Structures for Swapping on
Linux Systems

Department of Computer Science and Engineering


RAID Structure

• RAID – redundant array of inexpensive disks


• multiple disk drives provides reliability via redundancy
• Increases the mean time to failure
• Mean time to repair – exposure time when another failure could cause
data loss
• Mean time to data loss based on above factors
• If mirrored disks fail independently, consider disk with 1300,000 mean
time to failure and 10 hour mean time to repair
• Mean time to data loss is 100, 0002 / (2 ∗ 10) = 500 ∗ 106 hours, or
57,000 years!
• Frequently combined with NVRAM to improve write performance
• Several improvements in disk-use techniques involve the use of multiple
disks working cooperatively

Department of Computer Science and Engineering


RAID Structure

• Disk striping uses a group of disks as one storage unit


• RAID is arranged into six different levels
• RAID schemes improve performance and improve the reliability of the
storage system by storing redundant data
• Mirroring or shadowing (RAID 1) keeps duplicate of each disk
• Striped mirrors (RAID 1+0) or mirrored stripes (RAID 0+1) provides
high performance and high reliability
• Block interleaved parity (RAID 4, 5, 6) uses much less redundancy
• RAID within a storage array can still fail if the array fails, so automatic
replication of the data between arrays is common
• Frequently, a small number of hot-spare disks are left unallocated,
automatically replacing a failed disk and having data rebuilt onto them

Department of Computer Science and Engineering


RAID Levels

Department of Computer Science and Engineering


RAID (0 + 1) and (1 + 0)

Department of Computer Science and Engineering


File Concept

• Contiguous logical address space


• Types:
• Data
• numeric
• character
• binary
• Program
• Contents defined by file’s creator
• Many types
• Consider text file, source file, executable file

Department of Computer Science and Engineering


File Attributes

• Name – only information kept in human-readable form


• Identifier – unique tag (number) identifies file within file system
• Type – needed for systems that support different types
• Location – pointer to file location on device
• Size – current file size
• Protection – controls who can do reading, writing, executing
• Time, date, and user identification – data for protection, security, and usage
monitoring
• Information about files are kept in the directory structure, which is maintained
on the disk
• Many variations, including extended file attributes such as file checksum
• Information kept in the directory structure

Department of Computer Science and Engineering


File Operations

• File is an abstract data type


• Create
• Write – at write pointer location
• Read – at read pointer location
• Reposition within file - seek
• Delete
• Truncate
• Open(Fi) – search the directory structure on disk for entry Fi, and move
the content of entry to memory
• Close (Fi) – move the content of entry Fi in memory to directory
structure on disk

Department of Computer Science and Engineering


Open Files

• Several pieces of data are needed to manage open files:

• Open-file table: tracks open files

• File pointer: pointer to last read/write location, per process that has
the file open
• File-open count: counter of number of times a file is open – to allow
removal of data from open-file table when last processes closes it
• Disk location of the file: cache of data access information

• Access rights: per-process access mode information

Department of Computer Science and Engineering


Open File Locking

• Provided by some operating systems and file systems

• Similar to reader-writer locks

• Shared lock similar to reader lock – several processes can acquire


concurrently
• Exclusive lock similar to writer lock

• Mediates access to a file

• Mandatory or advisory:

• Mandatory – access is denied depending on locks held and requested

• Advisory – processes can find status of locks and decide what to do


Department of Computer Science and Engineering
File Types – Name, Extension

Department of Computer Science and Engineering


File Structure

• None - sequence of words, bytes


• Simple record structure
• Lines
• Fixed length
• Variable length
• Complex Structures
• Formatted document
• Relocatable load file
• Can simulate last two with first method by inserting appropriate control
characters
• Who decides:
• Operating system
• Program

Department of Computer Science and Engineering


Sequential-access File

Department of Computer Science and Engineering


Access Methods
• Sequential Access
read next
write next
reset
no read after last write
(rewrite)
• Direct Access – file is fixed length logical records
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
• Relative block numbers allow OS to decide where file should be placed

Department of Computer Science and Engineering


Simulation of Sequential Access on Direct-access File

Department of Computer Science and Engineering


Directory Structure

A collection of nodes containing information about all files

Directory

Files
F1 F2 F4
F3
Fn

Both the directory structure and the files reside on disk

Department of Computer Science and Engineering


Directory Structure

• Disk can be subdivided into partitions


• Disks or partitions can be RAID protected against failure
• Disk or partition can be used raw – without a file system, or formatted
with a file system
• Partitions also known as minidisks, slices
• Entity containing file system known as a volume
• Each volume containing file system also tracks that file system’s info in
device directory or volume table of contents
• As well as general-purpose file systems there are many special-
purpose file systems, frequently all within the same operating system or
computer
Department of Computer Science and Engineering
A Typical File-system Organization

Department of Computer Science and Engineering


Types of File Systems

• But systems frequently have may file systems, some general- and some special-
purpose

• Consider Solaris has

• tmpfs – memory-based volatile FS for fast, temporary I/O

• objfs – interface into kernel memory to get kernel symbols for debugging

• ctfs – contract file system for managing daemons

• lofs – loopback file system allows one FS to be accessed in place of another

• procfs – kernel interface to process structures

• ufs, zfs – general purpose file systems

Department of Computer Science and Engineering


Operations Performed on Directory

• Search for a file

• Create a file

• Delete a file

• List a directory

• Rename a file

• Traverse the file system

Department of Computer Science and Engineering


Directory Organization

• The directory is organized logically to obtain

• Efficiency – locating a file quickly

• Naming – convenient to users

• Two users can have same name for different files

• The same file can have several different names

• Grouping – logical grouping of files by properties, (e.g., all Java


programs, all games, …)

Department of Computer Science and Engineering


Single-Level Directory

• A single directory for all users

• Naming problem
• Grouping problem

Department of Computer Science and Engineering


Two-Level Directory

• Separate directory for each user

• Path name
• Can have the same file name for different user
• Efficient searching
• No grouping capability
Department of Computer Science and Engineering
Tree-Structured Directories

Department of Computer Science and Engineering


Tree-Structured Directories

• Efficient searching

• Grouping Capability

• Current directory (working directory)

• cd /spell/mail/prog

• type list

Department of Computer Science and Engineering


Tree-Structured Directories

• Absolute or relative path name

• Creating a new file is done in current directory

• Delete a file

rm <file-name>

• Creating a new subdirectory is done in current directory

mkdir <dir-name>

Example: if in current directory /mail

mkdir count

Department of Computer Science and Engineering


Tree-Structured Directories

Deleting “mail”  deleting the entire subtree rooted by “mail”

Department of Computer Science and Engineering


File Sharing

• Sharing of files on multi-user systems is desirable


• Sharing may be done through a protection scheme
• On distributed systems, files may be shared across a network
• Network File System (NFS) is a common distributed file-sharing method
• If multi-user system
• User IDs identify users, allowing permissions and protections to be per-
user
Group IDs allow users to be in groups, permitting group access rights
• Owner of a file / directory
• Group of a file / directory

Department of Computer Science and Engineering


File Sharing – Remote File Systems

• Uses networking to allow file system access between systems


• Manually via programs like FTP
• Automatically, seamlessly using distributed file systems
• Semi automatically via the world wide web
• Client-server model allows clients to mount remote file systems from servers
• Server can serve multiple clients
• Client and user-on-client identification is insecure or complicated
• NFS is standard UNIX client-server file sharing protocol
• CIFS is standard Windows protocol
• Standard operating system file calls are translated into remote calls
• Distributed Information Systems (distributed naming services) such as LDAP,
DNS, NIS, Active Directory implement unified access to information needed for
remote computing

Department of Computer Science and Engineering


File Sharing – Failure Modes

• All file systems have failure modes

• For example corruption of directory structures or other non-user data,


called metadata

• Remote file systems add new failure modes, due to network failure, server
failure

• Recovery from failure can involve state information about status of each
remote request

• Stateless protocols such as NFS v3 include all information in each request,


allowing easy recovery but less security

Department of Computer Science and Engineering


File Sharing – Consistency Semantics

• Specify how multiple users are to access a shared file simultaneously

• Similar to Ch 5 process synchronization algorithms

• Tend to be less complex due to disk I/O and network latency (for remote file
systems
• Andrew File System (AFS) implemented complex remote file sharing semantics

• Unix file system (UFS) implements:


• Writes to an open file visible immediately to other users of the same open file
• Sharing file pointer to allow multiple users to read and write concurrently
• AFS has session semantics
• Writes only visible to sessions starting after the file is closed

Department of Computer Science and Engineering


Protection

• File owner/creator should be able to control:

• what can be done

• by whom

• Types of access

• Read

• Write

• Execute

• Append

• Delete

• List

Department of Computer Science and Engineering


Access Lists and Groups
• Mode of access: read, write, execute
• Three classes of users on Unix / Linux
RWX
a) owner access 7  111
RWX
b) group access 6  110
RWX
c) public access 1  001
• Ask manager to create a group (unique name), say G, and add some users to
the group.
• For a particular file (say game) or subdirectory, define an appropriate access.

Attach a group to a file


chgrp G game
Department of Computer Science and Engineering
Windows 7 Access-Control List Management

Department of Computer Science and Engineering


A Sample UNIX Directory Listing

Department of Computer Science and Engineering


THANK YOU

Department of Computer Science and Engineering

You might also like