SlideShare a Scribd company logo
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Chapter 12: Disk Structure
12.2 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Moving-head Disk Mechanism
12.3 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Hard Disks
 Range from 30GB to 3TB per drive
 Seek Time: The time taken for a disk drive to
locate the area on the disk where the data to be
read is stored. (to particular track)
 Seek time from 3ms to 12ms – 9ms common
for desktop drives
 Seek time is normally expressed in
milliseconds (commonly abbreviated
"msec" or "ms"), with average seek times
for most modern drives today in a rather
tight range of 8 to 10 ms.
 Latency Time: The time taken by head to
access the required sector is known as
latency.
 Latency based on spindle speed
 1 / (RPM / 60) = 60 / RPM
(From Wikipedia)
12.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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
12.6 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Disk Scheduling (Cont.)
 There are many sources of disk I/O request
 OS
 System processes
 Users processes
 I/O request includes input or output mode, disk address, memory
address, number of sectors to transfer
 OS maintains queue of requests, per disk or device
 Idle disk can immediately work on I/O request, busy disk means
work must queue
 Optimization algorithms only make sense when a queue exists
12.7 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Disk Scheduling (Cont.)
 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
12.8 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
FCFS
Illustration shows total head movement of 640 cylinders
45+85+146+85+108+110+59+2
12.9 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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
12+2+30+23+84+24+2+59
12.10 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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 208 cylinders
 But note that if requests are uniformly dense, largest density at
other end of disk and those wait the longest
12.11 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
SCAN (Cont.)
12.12 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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?
12.13 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
C-SCAN (Cont.)
12.14 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
LOOK/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?
 It is called LOOK because they look for a request before
continuing to move in a given direction.
12.15 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
C-LOOK (Cont.)
12.16 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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
 Algorithms only consider seek distances, What about rotational latency?
 Difficult for OS to calculate because modern disks do not disclose
the physical location of logical blocks.
12.17 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Disk Management
It includes the following tasks
Low-level formatting
Logical formatting
Booting
Bad block recovery
 Swap space
12.18 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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
 When the controller writes a sector of data during normal I/O, the ECC is
updated with the value calculated from all the bytes in the data area. When the
sector is read, the ECC is recalculated and compared with stored value. If
mismatched, this means data is corrupted and the disk’s sector is bad.
 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
12.19 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Disk Management (Cont.)
 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
 Disks have moving parts and small tolerances, they are prone to failure.
Sometimes need backup media.
 Most disks even come from factory with bad blocks.
 E.g. MS-DOS formats and finds bad blocks. If found, it writes a special value into
the corresponding FAT entry to tell the allocation routine not to use it.
 More sophisticated disks like SCSI, maintains a list of bad blocks on the disk
and updated over the life of the disks. Low level formatting also set aside spare
sectors not visible to OS. The controller can be told to replace each bad sector
logically with one of the spare sectors called sector sparing .
12.20 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Booting from a Disk in Windows
Master Boot Record
12.21 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
21
Bad Blocks
 Disk sectors (blocks) may become defective. Can no longer store data.
 Hardware defect
 System should not put data there.
 Possible Strategy:
 A bad block X can be remapped to a good block Y
 Whenever OS tries to access X, disk controller accesses Y.
 Some sectors (blocks) of disk can be reserved for this mapping.
 This is called sector sparing.
12.22 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
22
Bad Blocks
x
z
y w Disk
Disk Controller
x y
z w
bad block mapping table
block (sector) request
bad sector
Table stored
on disk
spare sectors
12.23 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Bad Blocks
 Disk is having moving part as well as small tolerances, so prone to failure.
 To check for bad blocks, program ‘chkdsk’ can be used.
 In SCSI disks, ‘Sector Sparing’ method is used to handle with bad blocks.
Steps:
1) Find logical block 10
2) Calculates ECC and found it is bad block and send OS a message.
3) Reboot the system and tell SCSI controller to replace the block.
4) So whenever , 10th
block is referred automatically control goes to
replaced spare sector.
 Another method is ‘Sector Slipping’
12.24 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Disk Management (Cont.)
 Alternative to sector sparing is Sector Slipping.
 Methods such as sector sparing or sector slipping is used to handle bad blocks.
 Under sector sparing, a new sector is allocated to replace a bad sector.
 Under sector slipping: for example, if sector 20 becomes defective, and the first
available sector follows sector 202, then all sectors from 20 to 202 are remapped
moving them down one spot.
SECTOR SLIPPING: The Process of moving all the sectors down one position from
the bad sector is called as sector slipping.
Example: If the logical block 17 becomes defective and the first available spare
follows sector 202. Sector slipping then remaps all the sectors from 17 to 202,
moving them all down one spot. That is, sector 202 is copied into the spare, then
sector 201 into 202, then 200 into 201, and so on, until sector 18 is copied into
sector 19. Slipping the sectors in this way frees up the space of sector 18 so that
sector 17 can be mapped to it.
12.25 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
25
Disk Management
 Low-level formatting, or physical formatting — Dividing a disk into sectors
that the disk controller can read and write.
 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.
 Logical formatting or “making a file system”.
12.26 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
26
Low Level Formatting
Sector Sector Sector ….
magnetic material that can store bits
Disk before low level formatting
Disk after low level formatting
HDR ECC
Data (512 bytes)
sector number error correcting code
12.27 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
27
Boot Process
Tiny
Boot
program
ROM
RAM Disk
MBR
Boot Block
CPU
partition1
partition2
partition3
boot codepartition table
1. Boot code in
ROM is run; it brings
MBR into memory
and starts MBR boot
code
2. MBR boot code
runs; looks
to partition table;
learns about
the boot partition;
brings and starts the
boot code in the boot
partition
3. Boot code in boot
partition loads
the kernel sitting
in that partition
Power ON
kernel
12.28 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
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
 Kernel uses swap maps to track swap-space use
 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
12.29 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
 Swap space in Linux is used when the amount of physical memory
(RAM) is full. If the system needs more memory resources and the
RAM is full, inactive pages in memory are moved to the swap
space. While swap space can help machines with a small amount of
RAM, it should not be considered a replacement for more RAM.
Swap space is located on hard drives, which have a slower access
time than physical memory.
Swap-Space Management Cont…
12.30 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
 Since disk access is much slower than memory access, using swap space
significantly decreases system performance.
 Main goal of swap space is to provide the best throughput for the virtual
memory system.
Swap Space Use: Different ways
 Use swap space to hold the entire process image eg code, data. Paging
system may simply store pages that have been pushed out of main
memory.
 Some OS like UNIX, allow multiple swap spaces. These are put on
separate disks so that load placed on the I/O system by paging and
swapping can be spread over the system.
 It is safer to overestimate than to underestimate swap space, because if a
system runs out of swap space it may be forced to abort processes or may
crash entirely.
Swap-Space Management Cont…
12.31 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
Swap Space Location: can reside in two places
Can be carved out of the normal file system or
Can be in a separate disk partition
1.If normal file system, then can be used to create it, name it and allocate its
space. Easy approach but inefficient. Navigation of files and disk will take
time, extra disk access. External fragmentation will increase swapping time.
2.Separate swap space management is used to allocate and deallocate the
blocks. Good speed than storage efficiency. Internal fragmentation may
increase but acceptable as data in swap space is stored for shorter duration
and swap space area can be accessed much more efficiently. Swap space is
fixed during partition and if need to change then repartitioning is required.
3.Some OS like Solaris 2 is flexible and can use any of the method
depending upon need.
Swap-Space Management Cont…
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th
Edition
End of Chapter 12

More Related Content

PPT
Lecture12-Secondary Storage-PAhsjfhsjf.ppt
PPT
Physics.ppt 9th class physics important.
PPT
Mass Storage Structure Manipal University Jaipur PPT
PPTX
ch12-gh1.pptx
PPT
Mass_Storage_Structure_presentation.ppttx
PPT
ch10 Mass Storage Structure .ppt
PPT
chapter10.masss storge.memory management.ppt
PPTX
cs8493 - operating systems unit 4
Lecture12-Secondary Storage-PAhsjfhsjf.ppt
Physics.ppt 9th class physics important.
Mass Storage Structure Manipal University Jaipur PPT
ch12-gh1.pptx
Mass_Storage_Structure_presentation.ppttx
ch10 Mass Storage Structure .ppt
chapter10.masss storge.memory management.ppt
cs8493 - operating systems unit 4

Similar to Database Lecture12-Secondary Storage-PA.ppt (20)

PPT
ch10 Mass Storage Systems Operating System
PPT
Chapter 10: Mass-Storage Systems edition 9 schitezer
PPT
ch10.ppt- Cryptography and Network security
PPT
disk scheduling
PPT
Disk Management.ppt
PPT
ch14.ppt
PPT
12.mass stroage system
PPT
CH13-OS.PPTdfjhfgjkghkc kjbhkyuikgkmbv mh
PPT
Operating system presentation part 2 2025
PDF
Operating System : Ch13 secondary storage
PDF
ch10_massSt.pdf
PPT
File_System_Fundamentals savitchAbsJavaPPT Java Programming Part 2
PDF
Ch10.1 secondary storage
PPT
운영체제론 Ch13
PPTX
I/O structure slide by Rajalakshmi SKC
PPT
Disk Management through the Computer Management
PPT
Operating Systems
PPTX
PPTX
Mass Storage Structure
PPTX
Disk scheduling
ch10 Mass Storage Systems Operating System
Chapter 10: Mass-Storage Systems edition 9 schitezer
ch10.ppt- Cryptography and Network security
disk scheduling
Disk Management.ppt
ch14.ppt
12.mass stroage system
CH13-OS.PPTdfjhfgjkghkc kjbhkyuikgkmbv mh
Operating system presentation part 2 2025
Operating System : Ch13 secondary storage
ch10_massSt.pdf
File_System_Fundamentals savitchAbsJavaPPT Java Programming Part 2
Ch10.1 secondary storage
운영체제론 Ch13
I/O structure slide by Rajalakshmi SKC
Disk Management through the Computer Management
Operating Systems
Mass Storage Structure
Disk scheduling
Ad

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT
Project quality management in manufacturing
PPTX
UNIT 4 Total Quality Management .pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Welding lecture in detail for understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Construction Project Organization Group 2.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Project quality management in manufacturing
UNIT 4 Total Quality Management .pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Embodied AI: Ushering in the Next Era of Intelligent Systems
Welding lecture in detail for understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Sustainable Sites - Green Building Construction
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Construction Project Organization Group 2.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Ad

Database Lecture12-Secondary Storage-PA.ppt

  • 1. Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Chapter 12: Disk Structure
  • 2. 12.2 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Moving-head Disk Mechanism
  • 3. 12.3 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Hard Disks  Range from 30GB to 3TB per drive  Seek Time: The time taken for a disk drive to locate the area on the disk where the data to be read is stored. (to particular track)  Seek time from 3ms to 12ms – 9ms common for desktop drives  Seek time is normally expressed in milliseconds (commonly abbreviated "msec" or "ms"), with average seek times for most modern drives today in a rather tight range of 8 to 10 ms.  Latency Time: The time taken by head to access the required sector is known as latency.  Latency based on spindle speed  1 / (RPM / 60) = 60 / RPM (From Wikipedia)
  • 4. 12.5 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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
  • 5. 12.6 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Disk Scheduling (Cont.)  There are many sources of disk I/O request  OS  System processes  Users processes  I/O request includes input or output mode, disk address, memory address, number of sectors to transfer  OS maintains queue of requests, per disk or device  Idle disk can immediately work on I/O request, busy disk means work must queue  Optimization algorithms only make sense when a queue exists
  • 6. 12.7 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Disk Scheduling (Cont.)  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
  • 7. 12.8 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition FCFS Illustration shows total head movement of 640 cylinders 45+85+146+85+108+110+59+2
  • 8. 12.9 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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 12+2+30+23+84+24+2+59
  • 9. 12.10 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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 208 cylinders  But note that if requests are uniformly dense, largest density at other end of disk and those wait the longest
  • 10. 12.11 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition SCAN (Cont.)
  • 11. 12.12 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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?
  • 12. 12.13 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition C-SCAN (Cont.)
  • 13. 12.14 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition LOOK/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?  It is called LOOK because they look for a request before continuing to move in a given direction.
  • 14. 12.15 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition C-LOOK (Cont.)
  • 15. 12.16 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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  Algorithms only consider seek distances, What about rotational latency?  Difficult for OS to calculate because modern disks do not disclose the physical location of logical blocks.
  • 16. 12.17 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Disk Management It includes the following tasks Low-level formatting Logical formatting Booting Bad block recovery  Swap space
  • 17. 12.18 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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  When the controller writes a sector of data during normal I/O, the ECC is updated with the value calculated from all the bytes in the data area. When the sector is read, the ECC is recalculated and compared with stored value. If mismatched, this means data is corrupted and the disk’s sector is bad.  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
  • 18. 12.19 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Disk Management (Cont.)  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  Disks have moving parts and small tolerances, they are prone to failure. Sometimes need backup media.  Most disks even come from factory with bad blocks.  E.g. MS-DOS formats and finds bad blocks. If found, it writes a special value into the corresponding FAT entry to tell the allocation routine not to use it.  More sophisticated disks like SCSI, maintains a list of bad blocks on the disk and updated over the life of the disks. Low level formatting also set aside spare sectors not visible to OS. The controller can be told to replace each bad sector logically with one of the spare sectors called sector sparing .
  • 19. 12.20 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Booting from a Disk in Windows Master Boot Record
  • 20. 12.21 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 21 Bad Blocks  Disk sectors (blocks) may become defective. Can no longer store data.  Hardware defect  System should not put data there.  Possible Strategy:  A bad block X can be remapped to a good block Y  Whenever OS tries to access X, disk controller accesses Y.  Some sectors (blocks) of disk can be reserved for this mapping.  This is called sector sparing.
  • 21. 12.22 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 22 Bad Blocks x z y w Disk Disk Controller x y z w bad block mapping table block (sector) request bad sector Table stored on disk spare sectors
  • 22. 12.23 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Bad Blocks  Disk is having moving part as well as small tolerances, so prone to failure.  To check for bad blocks, program ‘chkdsk’ can be used.  In SCSI disks, ‘Sector Sparing’ method is used to handle with bad blocks. Steps: 1) Find logical block 10 2) Calculates ECC and found it is bad block and send OS a message. 3) Reboot the system and tell SCSI controller to replace the block. 4) So whenever , 10th block is referred automatically control goes to replaced spare sector.  Another method is ‘Sector Slipping’
  • 23. 12.24 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Disk Management (Cont.)  Alternative to sector sparing is Sector Slipping.  Methods such as sector sparing or sector slipping is used to handle bad blocks.  Under sector sparing, a new sector is allocated to replace a bad sector.  Under sector slipping: for example, if sector 20 becomes defective, and the first available sector follows sector 202, then all sectors from 20 to 202 are remapped moving them down one spot. SECTOR SLIPPING: The Process of moving all the sectors down one position from the bad sector is called as sector slipping. Example: If the logical block 17 becomes defective and the first available spare follows sector 202. Sector slipping then remaps all the sectors from 17 to 202, moving them all down one spot. That is, sector 202 is copied into the spare, then sector 201 into 202, then 200 into 201, and so on, until sector 18 is copied into sector 19. Slipping the sectors in this way frees up the space of sector 18 so that sector 17 can be mapped to it.
  • 24. 12.25 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 25 Disk Management  Low-level formatting, or physical formatting — Dividing a disk into sectors that the disk controller can read and write.  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.  Logical formatting or “making a file system”.
  • 25. 12.26 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 26 Low Level Formatting Sector Sector Sector …. magnetic material that can store bits Disk before low level formatting Disk after low level formatting HDR ECC Data (512 bytes) sector number error correcting code
  • 26. 12.27 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 27 Boot Process Tiny Boot program ROM RAM Disk MBR Boot Block CPU partition1 partition2 partition3 boot codepartition table 1. Boot code in ROM is run; it brings MBR into memory and starts MBR boot code 2. MBR boot code runs; looks to partition table; learns about the boot partition; brings and starts the boot code in the boot partition 3. Boot code in boot partition loads the kernel sitting in that partition Power ON kernel
  • 27. 12.28 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition 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  Kernel uses swap maps to track swap-space use  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
  • 28. 12.29 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory. Swap-Space Management Cont…
  • 29. 12.30 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition  Since disk access is much slower than memory access, using swap space significantly decreases system performance.  Main goal of swap space is to provide the best throughput for the virtual memory system. Swap Space Use: Different ways  Use swap space to hold the entire process image eg code, data. Paging system may simply store pages that have been pushed out of main memory.  Some OS like UNIX, allow multiple swap spaces. These are put on separate disks so that load placed on the I/O system by paging and swapping can be spread over the system.  It is safer to overestimate than to underestimate swap space, because if a system runs out of swap space it may be forced to abort processes or may crash entirely. Swap-Space Management Cont…
  • 30. 12.31 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition Swap Space Location: can reside in two places Can be carved out of the normal file system or Can be in a separate disk partition 1.If normal file system, then can be used to create it, name it and allocate its space. Easy approach but inefficient. Navigation of files and disk will take time, extra disk access. External fragmentation will increase swapping time. 2.Separate swap space management is used to allocate and deallocate the blocks. Good speed than storage efficiency. Internal fragmentation may increase but acceptable as data in swap space is stored for shorter duration and swap space area can be accessed much more efficiently. Swap space is fixed during partition and if need to change then repartitioning is required. 3.Some OS like Solaris 2 is flexible and can use any of the method depending upon need. Swap-Space Management Cont…
  • 31. Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9th Edition End of Chapter 12