SlideShare a Scribd company logo
POS - File System & Deadlocks
Presenter Rohit Jain
File System
• It is the way in which files are named and where they are placed logically for
storage and retrieval.
• A file system is used to control how information is stored and retrieved.
• Without file system, information placed in a storage area would be one large body
of information with no way to tell where one piece of information stops and the
next begins.
• A file system defines the structures and the rules used to read, write and maintain
information stored on a disk.
Aspects of File system
• Space management
• Filename
• Directories
• Metadata
• Restricting and permitting access
Space Management
• The File system is responsible for organizing files and directories and keeping
track of which areas of the media belongs to which file and which are not being
used.
• Slack Space
• File system fragmentation occurs when unused space or single files are not
contiguous. As file are deleted the space they were allocated eventually is
considered available for use by other files.This created alternating used and
unused areas of various sizes.
File Names
• A filename is used to identify a storage location In the file system. Most file
system have restrictions on the length of filenames. In some file system filenames
are case sensitive.
Directories
• File system typically have directories (folders) which allow user to group files into
separate collection.
• Directory structure may be linear or allow hierarchies where directory may contain
sub directory.
Metadata
• Meta Data is data about data and in filesystem it is associated as bookkeeping
information is typically associated with each file within a file system.The length of
the data contained in a file may be stored as the number of blocks allocated for
the file or as the byte count.
Restricting and Permitting access
• There are several mechanisms used by file system to control access to data.
Usually the intent is to prevent reading or modifying files by user or group of users.
Another reason is to ensure data is modified in a controlled way so access may be
restricted to a specific program.
• For Example Includes Password stored in the metadata of the file.
Types of File System
• Disk File system
• Flash File system
• Database file system
• Network file system
• Special file system
Disk file system
• A disk file system takes advantages of the ability of disk storage media to
randomly address data in a short amount of time.
• Additionally Consideration include the speed of accessing data following that
initially requested and the anticipation that the following data may be requested.
• For example ext3, NTFS, UDF etc.
Flash file system
• A flash file system considers the special abilities, performance restrictions of flash
memory devices.
• Frequently a disk file system can use a flash memory device as the underlying
storage media but it is much better to use a file system that is Specifically
designed for a flash device.
Database File system
• In this file are identified be their characteristics, like type, author or any other Rich
metadata instead of hierarchical structured management..
• IBM DB2 is a database file system.
Network File system
• A network file system is a file system that acts as a client for a remote file access
protocol, providing access to files on a server.
• For example AFS, FTP,WebDAV.
Shared Disk File system
• A shared disk file system is one in which a number of machine all have access to
the same external disk subsystem.
• The file system arbitrates access to that subsystem, Preventing write collisions.
• For example GFS 2 , GPFS etc.
Special File system
• A special File system presents non-file elements of an OS as files so they can be
acted on using system APIs.This is most commonly done in Unix Like Operating
System but devices are given file names in some non-unix-like Operating systems
as well.
File Attributes
• Name
• Type
• Protection
• Location
• Size
File Operations
• Creata :- Find spaces on disk and make entyr in directory
• Write : wirte to file requires positioning with ithe file
• Read : read from file involves positioning within the file
• Delete :- Delete Directory enry, redaim disk space
• Reposition Move read / write position.
Files access Methods
• Sequential :- readNext, writenext, Reset
• Direct :- readRecord N,WirteRecord N PostoionAt N, reset
• Indexed :- readRecord Key,Write Record Key , PositionAt Key, reset
File AllocationTable
• Where the OS record s how the disk spece is used,
• Location of FAT near the beginning og the volume
• Locatoin of FAT is specified in the boot sector
FATTypes
• FAT12 :-The earliest version the file system, FAT12 allow a partition to containg up
to 4096MB/ (212) clusters
• FAT16 :- oldest, created for DOS, supported by most OS’s cannot be installed on
partitions laeger than 2 GB, or on hard dreives larger than 4 GB
• FAT32 :- Supports disk from 512MB to 2TB, compatible with windows98 upto
latest.
NTFS
• NewTechnology File System
• Better File Security ( Encryption File system)
• Disk Compressoin – can compress a file/ folder
• NTFS volmes can not be accessed by DOS
Operating System FAT16 FAT32 NTFS
Windows XP
Windows 2000
Windows NT
Windows 95, 98, ME
Windows 95
MS-DOS
Formatting Process
• Full Format
• Quick Format
Disk Scheduling
• The OS is responsible for using hardware efficiently for the disk drives
• Access time
Total access time = seek time + rotational delay + data transfer time
Seek time – time required to move the disk arm to the required track
Rotational delay – time required to rotate the disk to the required sector
Data transfer time – time to read/write data from/to the disk
• Disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for
service and the completion of last transfer.
• OS maintains queue of request, per disk or device.
Disk SchedulingAlgorithms
SeveralAlgorithms exist to schedule the servicing of disk I/O requests.
• FCFS
• SSTF
• SCAN
• C-Scan
• Look
• C-Look
Queue = 98, 183, 37, 122, 14, 124, 65, 67
Head starts at 53
First Come First Serve
• Handle I/o request Sequentially
• Fair at all Processes
• Approaches reandom scheduling in performance scheduling in performance if
there are many processes/ request.
Shortest SeekTime First
• Selects the request with the minimum seek time from the current head position.
• SSSTF scheduling is a form of SJF scheduling may cause starvation of some
requests.
SCAN
• The disk arm starts at one end of the disk , and moves toward the other end,
servicing requests until it get to the other end of the disk, where the head
movement is reversed and servicing continues.
• It moves in both directions until both ends
• Tends to stay more at the ends so more fair to the extreme cylinder requests
C-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.
• Provides a more uniform wait time than SCAN; it treats all cylinders in
the same manner.
C- Look
• Look 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.
• In general, Circular versions are more fair but pay with a larger total seek
time.
• Scan versions have a larger total seek time than the corresponding Look
versions.
Selecting a Disk SchedulingAlgorithm
• Performance depends on the number and types of requests.
• Requests for disk service can be influenced by the file-allocation method.
• 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.
• With low load on the disk, It’s FCFS anyway. SSTF is common and has a
natural appeal – good for medium disk load.
• SCAN and C-SCAN perform better for systems that place a heavy load
on the disk; Less starvation.
• Either SSTF or LOOK is a reasonable choice for the default algorithm.
Dead Lock
• Deadlock: processes waiting indefinitely
with no chance of making progress.
• Starvation: a process waits for a long time
to make progress.
Deadlocks
• Deadlock applications not just OS
– Network
• Two processes may be blocking a send message
to the other process if they are both waiting for a
message from the other process
» Receive/waiting blocks writing
– Databases.
– Spooling/streaming data.
Deadlock Characterization
• Mutual exclusion: Only one process at a time can use a resource.
• Hold and wait: A process holding at least one resource is waiting to
acquire additional resources held by other processes.
• No preemption: A resource can be released only voluntarily by the
process holding it, after that process has completed its task.
• Circular wait: there exists a set {P0, P1, …, P0} of waiting
processes such that P0 is waiting for a resource that is held by P1,
P1 is waiting for a resource that is held by
P2, …, Pn–1 is waiting for a resource that is held by
Pn, and P0 is waiting for a resource that is held by P0.
Resource-Allocation Graph
• V is partitioned into two types:
– P = {P1, P2, …, Pn}, the set consisting of all
the processes in the system.
– R = {R1, R2, …, Rm}, the set consisting of
all resource types in the system.
request edge – directed edge P1  Rj
assignment edge – directed edge Rj 
Pi
•
•
A set of vertices V and a set of edges E.
Resource-Allocation Graph
• Process
• Resource Type with 4 instances
• Pi requests instance of
Rj
• Pi is holding an instance of
Rj
Pi
Rj
Pi
Rj
Example of a Resource Allocation
Graph
Resource Allocation Graph With A
Deadlock
Basic Facts
• If graph contains no cycles  no deadlock.
• If graph contains a cycle 
– if only one instance per resource type,
then deadlock.
– if several instances per resource type, possibility
of
deadlock.
Methods for Handling Deadlocks
• Ensure that the system will never enter
a deadlock state.
• Allow the system to enter a deadlock state
and
then recover.
• Ignore the problem and pretend that
deadlocks never occur in the system; used by
most operating systems, including UNIX.
Deadlock Prevention
• Mutual Exclusion – not required for sharable
resources; must hold for nonsharable
resources.
• Hold and Wait – must guarantee that whenever
a process requests a resource, it does not hold
any other resources.
– Require process to request and be allocated all its
resources before it begins execution, or allow process
to request resources only when the process has none.
– Low resource utilization; starvation possible.
Deadlock Prevention
• No Preemption –
– If a process that is holding some resources requests
another resource that cannot be immediately allocated to
it, then all resources currently being held are released.
– Preempted resources are added to the list of resources
for which the process is waiting.
– Process will be restarted only when it can regain its old
resources, as well as the new ones that it is requesting.
• Circular Wait – impose a total ordering of all
resource types, and require that each
process requests resources in an increasing
order of enumeration.
Deadlock Avoidance
• Simplest and most useful model requires that each process
declare the maximum number of resources of each type
that it may need.
• The deadlock-avoidance algorithm dynamically examines
the resource-allocation state to ensure that there can
never be a circular-wait condition.
• Resource-allocation state is defined by the number of
available and allocated resources, and the maximum
demands of the processes.
Requires that the system has some additional a priori
information available.
Banker’s Algorithm
Multiple instances
Each process must a priori claim of the maximum use.
When a process requests a resource it may have to wait.
When a process gets all its resources, it must return them in a
finite amount of time.
Data Structures for Banker’s Algorithm
n = number of processes, and m = number of resources types
Available: vector of length m.
• If Available[j ] = k, there are k instances of resource type Rj
available.
Max: n × m matrix.
• If Max[i , j ] = k, then process Pi may request at most k instances of
resource type Rj .
Allocation: n × m matrix.
• If Allocation[i , j ] = k then Pi is currently allocated k instances of
Rj .
Need: n × m matrix.
• If Need[i , j ] = k, then Pi may need k more instances of Rj to
complete its task Need[i , j ] = Max[i , j ] − Allocation[i , j ]
Resource-Request Algorithm for Process Pi
Requesti= request vector for process Pi . If Requesti [j ] = k, then
process Pi wants k instances of resource type Rj .
1. If Requesti ≤ Needi , go to step 2. Otherwise, raise error
condition, since process has exceeded its maximum claim.
2. If Requesti ≤ Available, go to step 3. Otherwise Pimust wait, since
resources are not available.
Resource-Request Algorithm for Process Pi
• If safe: the resources are allocated to Pi
• If unsafe: Pi must wait, and the old resource-allocation state is restored
3. Pretend to allocate requested resources to Pi
state as follows:
Available = Available − Requesti
Allocationi = Allocationi + Requesti Needi = Needi
− Requesti
Banker’s Algorithm Example
5 processes: P0 through P4
3 resource types:
• A (10 instances), B (5 instances), and C (7
instances)
Snapshot at time
T0
Banker’s Algorithm Example
(2/2)
The content of the matrix Need is defined to be Max −
Allocation
Is the system safe? (P1, P3, P4, P2, P0) satisfies safety
criteria.
Deadlock Detection
Allow system to enter deadlock state
Detection algorithm
Recovery scheme
Single Instance of Each Resource Type
Maintain wait-for graph.
• Nodes are processes.
• Pi → Pj if Pi is waiting for Pj
.
Periodically invoke an algorithm that searches for a cycle in
the graph.
If there is a cycle, there exists a
deadlock.
An algorithm to detect a cycle in a graph requires an
O(n2)
operations, where n is the number of vertices in the
graph.
Resource-Allocation Graph and Wait-for
Graph
Resource-al ocation
graph
Corresponding Wait-for
graph
Recovery from Deadlock
Process termination
Resource preemption
Process Termination
Abort all deadlocked processes.
Abort one process at a time until the deadlock cycle is eliminated
In which order should we choose to abort?
Priority of the process.
How long process has computed, and how much longer to completion.
Resources the process has used. Resources process
needs to complete.
How many processes will need to be terminated. Is process
interactive or batch.
Resource Preemption
Selecting a victim: minimize cost
Rollback: return to some safe state, restart process for that state.
Starvation: same process may always be picked as victim, include
number of rollback in cost factor.
Summary
Four simultaneous conditions: mutual exclusion, hold and wait, no preemption,
circular wait
Deadlock prevention:
Deadlock avoidance: resource-allocation algorithm, banker’s algo- rithm
Deadlock detection: Wait-for graph
Deadlock recovery: process termination, resource preemption
File system and Deadlocks

More Related Content

PDF
Transaction & Concurrency Control
PPT
Two phase commit protocol in dbms
PPT
2 PHASE COMMIT PROTOCOL
PPTX
Top down and botttom up Parsing
PPTX
Procedural programming
PPT
Deadlock Detection in Distributed Systems
PPTX
CLR AND LALR PARSER
PPTX
Loops in flow
Transaction & Concurrency Control
Two phase commit protocol in dbms
2 PHASE COMMIT PROTOCOL
Top down and botttom up Parsing
Procedural programming
Deadlock Detection in Distributed Systems
CLR AND LALR PARSER
Loops in flow

What's hot (20)

PPTX
File access method
PPTX
Functional dependencies in Database Management System
PDF
Directory services
PPT
7. Relational Database Design in DBMS
PPTX
Concurrency control
PPTX
Acid properties
PDF
6 two phasecommit
PPTX
Desired properties of a big data system
PDF
Database Design and Implementation
PPT
FSMO.ppt
PPTX
SUN Network File system - Design, Implementation and Experience
PPTX
Compiler Design LR parsing SLR ,LALR CLR
PDF
Dbms 14: Relational Calculus
PPT
remote procedure calls
PPTX
Join dependency
PPT
Process Synchronization
PPTX
2 phase locking protocol DBMS
DOCX
Concurrency Control Techniques
PPTX
Dns server
PPT
Distributed objects & components of corba
File access method
Functional dependencies in Database Management System
Directory services
7. Relational Database Design in DBMS
Concurrency control
Acid properties
6 two phasecommit
Desired properties of a big data system
Database Design and Implementation
FSMO.ppt
SUN Network File system - Design, Implementation and Experience
Compiler Design LR parsing SLR ,LALR CLR
Dbms 14: Relational Calculus
remote procedure calls
Join dependency
Process Synchronization
2 phase locking protocol DBMS
Concurrency Control Techniques
Dns server
Distributed objects & components of corba
Ad

Similar to File system and Deadlocks (20)

PPTX
File Management & Access Control
PPTX
Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PDF
Ch10 file system interface
PPTX
UNIT 4-UNDERSTANDING VIRTUAL MEMORY.pptx
PDF
Course 102: Lecture 26: FileSystems in Linux (Part 1)
PPT
operating system File - System Interface
PDF
Course 102: Lecture 27: FileSystems in Linux (Part 2)
PDF
19IS305_U4_LP10_LM10-22-23.pdf
PDF
Introduction to distributed file systems
PPTX
UNIT7-FileMgmt.pptx
PPTX
Lecture 1.pptx cs field hacing info on machine learning
PPTX
18CSC205J Operating Systemkooks-Unit-5.pptx
PDF
ITFT_File system interface in Operating System
PPTX
system admin Backups Disaster Recovery .pptx
PPTX
OS Unit5.pptx
PPTX
Backups _Disaster_Recovery for 202 .pptx
PPTX
FAT.pptx
PPT
File Management & Access Control
Unit 5.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Ch10 file system interface
UNIT 4-UNDERSTANDING VIRTUAL MEMORY.pptx
Course 102: Lecture 26: FileSystems in Linux (Part 1)
operating system File - System Interface
Course 102: Lecture 27: FileSystems in Linux (Part 2)
19IS305_U4_LP10_LM10-22-23.pdf
Introduction to distributed file systems
UNIT7-FileMgmt.pptx
Lecture 1.pptx cs field hacing info on machine learning
18CSC205J Operating Systemkooks-Unit-5.pptx
ITFT_File system interface in Operating System
system admin Backups Disaster Recovery .pptx
OS Unit5.pptx
Backups _Disaster_Recovery for 202 .pptx
FAT.pptx
Ad

More from Rohit Jain (9)

PPTX
VR - Virtual reality
PPTX
Social media
PPTX
Lifi - Light Fidelity
PPTX
Artificial intelligence
PPTX
Sutherlands Cohen and Hodgeman algorithms
PPTX
Introduction about Processors
PPTX
Overview On water
PPTX
Advance peripheral devices
PPTX
Big Data
VR - Virtual reality
Social media
Lifi - Light Fidelity
Artificial intelligence
Sutherlands Cohen and Hodgeman algorithms
Introduction about Processors
Overview On water
Advance peripheral devices
Big Data

Recently uploaded (20)

PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Digital Logic Computer Design lecture notes
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
web development for engineering and engineering
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
PPT on Performance Review to get promotions
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
OOP with Java - Java Introduction (Basics)
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Model Code of Practice - Construction Work - 21102022 .pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Foundation to blockchain - A guide to Blockchain Tech
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Structs to JSON How Go Powers REST APIs.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Digital Logic Computer Design lecture notes
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Geodesy 1.pptx...............................................
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
web development for engineering and engineering
CH1 Production IntroductoryConcepts.pptx
PPT on Performance Review to get promotions
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Lecture Notes Electrical Wiring System Components
OOP with Java - Java Introduction (Basics)
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT

File system and Deadlocks

  • 1. POS - File System & Deadlocks Presenter Rohit Jain
  • 2. File System • It is the way in which files are named and where they are placed logically for storage and retrieval. • A file system is used to control how information is stored and retrieved. • Without file system, information placed in a storage area would be one large body of information with no way to tell where one piece of information stops and the next begins. • A file system defines the structures and the rules used to read, write and maintain information stored on a disk.
  • 3. Aspects of File system • Space management • Filename • Directories • Metadata • Restricting and permitting access
  • 4. Space Management • The File system is responsible for organizing files and directories and keeping track of which areas of the media belongs to which file and which are not being used. • Slack Space • File system fragmentation occurs when unused space or single files are not contiguous. As file are deleted the space they were allocated eventually is considered available for use by other files.This created alternating used and unused areas of various sizes.
  • 5. File Names • A filename is used to identify a storage location In the file system. Most file system have restrictions on the length of filenames. In some file system filenames are case sensitive.
  • 6. Directories • File system typically have directories (folders) which allow user to group files into separate collection. • Directory structure may be linear or allow hierarchies where directory may contain sub directory.
  • 7. Metadata • Meta Data is data about data and in filesystem it is associated as bookkeeping information is typically associated with each file within a file system.The length of the data contained in a file may be stored as the number of blocks allocated for the file or as the byte count.
  • 8. Restricting and Permitting access • There are several mechanisms used by file system to control access to data. Usually the intent is to prevent reading or modifying files by user or group of users. Another reason is to ensure data is modified in a controlled way so access may be restricted to a specific program. • For Example Includes Password stored in the metadata of the file.
  • 9. Types of File System • Disk File system • Flash File system • Database file system • Network file system • Special file system
  • 10. Disk file system • A disk file system takes advantages of the ability of disk storage media to randomly address data in a short amount of time. • Additionally Consideration include the speed of accessing data following that initially requested and the anticipation that the following data may be requested. • For example ext3, NTFS, UDF etc.
  • 11. Flash file system • A flash file system considers the special abilities, performance restrictions of flash memory devices. • Frequently a disk file system can use a flash memory device as the underlying storage media but it is much better to use a file system that is Specifically designed for a flash device.
  • 12. Database File system • In this file are identified be their characteristics, like type, author or any other Rich metadata instead of hierarchical structured management.. • IBM DB2 is a database file system.
  • 13. Network File system • A network file system is a file system that acts as a client for a remote file access protocol, providing access to files on a server. • For example AFS, FTP,WebDAV.
  • 14. Shared Disk File system • A shared disk file system is one in which a number of machine all have access to the same external disk subsystem. • The file system arbitrates access to that subsystem, Preventing write collisions. • For example GFS 2 , GPFS etc.
  • 15. Special File system • A special File system presents non-file elements of an OS as files so they can be acted on using system APIs.This is most commonly done in Unix Like Operating System but devices are given file names in some non-unix-like Operating systems as well.
  • 16. File Attributes • Name • Type • Protection • Location • Size
  • 17. File Operations • Creata :- Find spaces on disk and make entyr in directory • Write : wirte to file requires positioning with ithe file • Read : read from file involves positioning within the file • Delete :- Delete Directory enry, redaim disk space • Reposition Move read / write position.
  • 18. Files access Methods • Sequential :- readNext, writenext, Reset • Direct :- readRecord N,WirteRecord N PostoionAt N, reset • Indexed :- readRecord Key,Write Record Key , PositionAt Key, reset
  • 19. File AllocationTable • Where the OS record s how the disk spece is used, • Location of FAT near the beginning og the volume • Locatoin of FAT is specified in the boot sector
  • 20. FATTypes • FAT12 :-The earliest version the file system, FAT12 allow a partition to containg up to 4096MB/ (212) clusters • FAT16 :- oldest, created for DOS, supported by most OS’s cannot be installed on partitions laeger than 2 GB, or on hard dreives larger than 4 GB • FAT32 :- Supports disk from 512MB to 2TB, compatible with windows98 upto latest.
  • 21. NTFS • NewTechnology File System • Better File Security ( Encryption File system) • Disk Compressoin – can compress a file/ folder • NTFS volmes can not be accessed by DOS
  • 22. Operating System FAT16 FAT32 NTFS Windows XP Windows 2000 Windows NT Windows 95, 98, ME Windows 95 MS-DOS
  • 23. Formatting Process • Full Format • Quick Format
  • 24. Disk Scheduling • The OS is responsible for using hardware efficiently for the disk drives • Access time Total access time = seek time + rotational delay + data transfer time Seek time – time required to move the disk arm to the required track Rotational delay – time required to rotate the disk to the required sector Data transfer time – time to read/write data from/to the disk • Disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for service and the completion of last transfer. • OS maintains queue of request, per disk or device.
  • 25. Disk SchedulingAlgorithms SeveralAlgorithms exist to schedule the servicing of disk I/O requests. • FCFS • SSTF • SCAN • C-Scan • Look • C-Look Queue = 98, 183, 37, 122, 14, 124, 65, 67 Head starts at 53
  • 26. First Come First Serve • Handle I/o request Sequentially • Fair at all Processes • Approaches reandom scheduling in performance scheduling in performance if there are many processes/ request.
  • 27. Shortest SeekTime First • Selects the request with the minimum seek time from the current head position. • SSSTF scheduling is a form of SJF scheduling may cause starvation of some requests.
  • 28. SCAN • The disk arm starts at one end of the disk , and moves toward the other end, servicing requests until it get to the other end of the disk, where the head movement is reversed and servicing continues. • It moves in both directions until both ends • Tends to stay more at the ends so more fair to the extreme cylinder requests
  • 29. C-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. • Provides a more uniform wait time than SCAN; it treats all cylinders in the same manner.
  • 30. C- Look • Look 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. • In general, Circular versions are more fair but pay with a larger total seek time. • Scan versions have a larger total seek time than the corresponding Look versions.
  • 31. Selecting a Disk SchedulingAlgorithm • Performance depends on the number and types of requests. • Requests for disk service can be influenced by the file-allocation method. • 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. • With low load on the disk, It’s FCFS anyway. SSTF is common and has a natural appeal – good for medium disk load.
  • 32. • SCAN and C-SCAN perform better for systems that place a heavy load on the disk; Less starvation. • Either SSTF or LOOK is a reasonable choice for the default algorithm.
  • 33. Dead Lock • Deadlock: processes waiting indefinitely with no chance of making progress. • Starvation: a process waits for a long time to make progress.
  • 34. Deadlocks • Deadlock applications not just OS – Network • Two processes may be blocking a send message to the other process if they are both waiting for a message from the other process » Receive/waiting blocks writing – Databases. – Spooling/streaming data.
  • 35. Deadlock Characterization • Mutual exclusion: Only one process at a time can use a resource. • Hold and wait: A process holding at least one resource is waiting to acquire additional resources held by other processes. • No preemption: A resource can be released only voluntarily by the process holding it, after that process has completed its task. • Circular wait: there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and P0 is waiting for a resource that is held by P0.
  • 36. Resource-Allocation Graph • V is partitioned into two types: – P = {P1, P2, …, Pn}, the set consisting of all the processes in the system. – R = {R1, R2, …, Rm}, the set consisting of all resource types in the system. request edge – directed edge P1  Rj assignment edge – directed edge Rj  Pi • • A set of vertices V and a set of edges E.
  • 37. Resource-Allocation Graph • Process • Resource Type with 4 instances • Pi requests instance of Rj • Pi is holding an instance of Rj Pi Rj Pi Rj
  • 38. Example of a Resource Allocation Graph
  • 39. Resource Allocation Graph With A Deadlock
  • 40. Basic Facts • If graph contains no cycles  no deadlock. • If graph contains a cycle  – if only one instance per resource type, then deadlock. – if several instances per resource type, possibility of deadlock.
  • 41. Methods for Handling Deadlocks • Ensure that the system will never enter a deadlock state. • Allow the system to enter a deadlock state and then recover. • Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX.
  • 42. Deadlock Prevention • Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources. • Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources. – Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none. – Low resource utilization; starvation possible.
  • 43. Deadlock Prevention • No Preemption – – If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released. – Preempted resources are added to the list of resources for which the process is waiting. – Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting. • Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.
  • 44. Deadlock Avoidance • Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. • The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition. • Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes. Requires that the system has some additional a priori information available.
  • 45. Banker’s Algorithm Multiple instances Each process must a priori claim of the maximum use. When a process requests a resource it may have to wait. When a process gets all its resources, it must return them in a finite amount of time.
  • 46. Data Structures for Banker’s Algorithm n = number of processes, and m = number of resources types Available: vector of length m. • If Available[j ] = k, there are k instances of resource type Rj available. Max: n × m matrix. • If Max[i , j ] = k, then process Pi may request at most k instances of resource type Rj . Allocation: n × m matrix. • If Allocation[i , j ] = k then Pi is currently allocated k instances of Rj . Need: n × m matrix. • If Need[i , j ] = k, then Pi may need k more instances of Rj to complete its task Need[i , j ] = Max[i , j ] − Allocation[i , j ]
  • 47. Resource-Request Algorithm for Process Pi Requesti= request vector for process Pi . If Requesti [j ] = k, then process Pi wants k instances of resource type Rj . 1. If Requesti ≤ Needi , go to step 2. Otherwise, raise error condition, since process has exceeded its maximum claim. 2. If Requesti ≤ Available, go to step 3. Otherwise Pimust wait, since resources are not available.
  • 48. Resource-Request Algorithm for Process Pi • If safe: the resources are allocated to Pi • If unsafe: Pi must wait, and the old resource-allocation state is restored 3. Pretend to allocate requested resources to Pi state as follows: Available = Available − Requesti Allocationi = Allocationi + Requesti Needi = Needi − Requesti
  • 49. Banker’s Algorithm Example 5 processes: P0 through P4 3 resource types: • A (10 instances), B (5 instances), and C (7 instances) Snapshot at time T0
  • 50. Banker’s Algorithm Example (2/2) The content of the matrix Need is defined to be Max − Allocation Is the system safe? (P1, P3, P4, P2, P0) satisfies safety criteria.
  • 51. Deadlock Detection Allow system to enter deadlock state Detection algorithm Recovery scheme
  • 52. Single Instance of Each Resource Type Maintain wait-for graph. • Nodes are processes. • Pi → Pj if Pi is waiting for Pj . Periodically invoke an algorithm that searches for a cycle in the graph. If there is a cycle, there exists a deadlock. An algorithm to detect a cycle in a graph requires an O(n2) operations, where n is the number of vertices in the graph.
  • 53. Resource-Allocation Graph and Wait-for Graph Resource-al ocation graph Corresponding Wait-for graph
  • 54. Recovery from Deadlock Process termination Resource preemption
  • 55. Process Termination Abort all deadlocked processes. Abort one process at a time until the deadlock cycle is eliminated In which order should we choose to abort? Priority of the process. How long process has computed, and how much longer to completion. Resources the process has used. Resources process needs to complete. How many processes will need to be terminated. Is process interactive or batch.
  • 56. Resource Preemption Selecting a victim: minimize cost Rollback: return to some safe state, restart process for that state. Starvation: same process may always be picked as victim, include number of rollback in cost factor.
  • 57. Summary Four simultaneous conditions: mutual exclusion, hold and wait, no preemption, circular wait Deadlock prevention: Deadlock avoidance: resource-allocation algorithm, banker’s algo- rithm Deadlock detection: Wait-for graph Deadlock recovery: process termination, resource preemption

Editor's Notes

  • #3: By separating the information into individual pieces and giving each piece a name, the information is easily separated and identified. Taking its name from the way paper based information system are named, each piece of information is called a “file” The structure and logic rules used to manage the groups of information their names is called a “file system”. Different structure and logic, properties of speed, flexibility, security, size. Iso file system of disk Different storage devices with differene media. Hard drive is coated with magnetic film. File system are used to implement type of data store, retrieve and update. File system referse to either he abstract data structures used to define files, actual software or firmware.
  • #5: When a file is created and there is not an area of contiguous space available for its initial allocation the space must be assigned in fragments. When a file is modified such that it becomes larger it may exceed the space initially allocated to it, another allocation must be assigned elsewhere and the file becomes fragmented.
  • #6: Modern File system have wide range of chatacter.
  • #8: File system might store the file creation time, the time it was last modified or the last time it was backed up. Other information can include the file's device type (e.g. block, character, socket, subdirectory, etc.), its owner user ID and group ID, its access permissions and other file attributes (e.g. whether the file is read-only, executable, etc.).
  • #9: Methods for encrypting file data are sometimes included in the file system. This is very effective since there is no need for file system utilities to know the encryption seed to effectively manage the data.
  • #17: Name :- Provide Handle for reference Dos (8 char + 3 ext.), Windows ( unlimited Length) Unix ( spaces tricky, no extension needed) Type:- Indicates how the file should be treated DOS/Windows rely on extension, can map extensions to programs Mac associates creator attribute with each file (OS X?) UNIX uses "magic number", first few bytes of file specify file type For example MS-DOS Filsnames Name 1 to 8 char Extension 1 to 3 char Dos only uses uppercase without spaces and special character.
  • #22: Recovery features-each file operation broken down into atomic transactions. maintains a transaction log – updates disk after each transaction if failure occurs during a transaction, info is sufficient to complete or rollback if a bad sector is found when writing, will automatically map to a different sector
  • #24: Full Format lays down new tracks and sectors, Verifies the integrity of each sector. By doing a surface scan – OS will put dummy data into sectors and then try to read the sector Quick Format: - Remove files Does not check for defective sectors
  • #25: Seek time is the time for the disk are to move the heads to the cylinder containing the desired sector. Rotational latency is the additional time waiting for the disk to rotate the desired sector to the disk head.