SlideShare a Scribd company logo
OPERATING SYSTEMS
v-1
Unit-V File SYSTEMS
OPERATING SYSTEMS
v-2
Kernel I/O Subsystem
 Scheduling
o Some I/O request ordering via per-device queue
o Some OSs try fairness
 Buffering - store data in memory while transferring between devices
o To cope with device speed mismatch
o To cope with device transfer size mismatch
o To maintain “copy semantics”
Device-status Table
Sun Enterprise 6000 Device-Transfer Rates
OPERATING SYSTEMS
v-3
 Caching - fast memory holding copy of data
o Always just a copy
o Key to performance
 Spooling - hold output for a device
o If device can serve only one request at a time
o i.e., Printing
 Device reservation - provides exclusive access to a device
o System calls for allocation and deallocation
o Watch out for deadlock
Error Handling
 OS can recover from disk read, device unavailable, transient write failures
 Most return an error number or code when I/O request fails
 System error logs hold problem reports
I/O Protection
 User process may accidentally or purposefully attempt to disrupt normal operation via
illegal I/O instructions
o All I/O instructions defined to be privileged
o I/O must be performed via system calls
 Memory-mapped and I/O port memory locations must be protected too
OPERATING SYSTEMS
v-4
Use of a System Call to Perform I/O
Kernel Data Structures
 Kernel keeps state info for I/O components, including open file tables, network
connections, character device state
 Many, many complex data structures to track buffers, memory allocation, “dirty”
blocks
 Some use object-oriented methods and message passing to implement I/O
UNIX I/O Kernel Structure
OPERATING SYSTEMS
v-5
I/O Requests to Hardware Operations
 Consider reading a file from disk for a process:
o Determine device holding file
o Translate name to device representation
o Physically read data from disk into buffer
o Make data available to requesting process
o Return control to process
Life Cycle of an I/O Request
13.4 STREAMS
 STREAM – a full-duplex communication channel between a user-level process and a
device in Unix System V and beyond
 A STREAM consists of:
- STREAM head interfaces with the user process
- driver end interfaces with the device
- zero or more STREAM modules between them.
 Each module contains a read queue and a write queue
OPERATING SYSTEMS
v-6
 Message passing is used to communicate between queues
The STREAMS Structure
13.5 Performance
 I/O a major factor in system performance:
o Demands CPU to execute device driver, kernel I/O code
o Context switches due to interrupts
o Data copying
o Network traffic especially stressful
Intercomputer Communications
OPERATING SYSTEMS
v-7
Improving Performance
 Reduce number of context switches
 Reduce data copying
 Reduce interrupts by using large transfers, smart controllers, polling
 Use DMA
 Balance CPU, memory, bus, and I/O performance for highest throughput
Device-Functionality Progression
OPERATING SYSTEMS
v-8
Kernels provide many services related to I/O. Several services are given below
1. The management of the name space for file and devices
2. Access control to files and devices
3. Operation control (for example, a modem cannot seek ())
4. File System space allocation
5. Device allocation
6. Buffering, caching, and spooling
7. I/O scheduling
8. Device status monitoring, error handling and failure recovery
9. Device driver configuration and initialization
1. Access control to files and device
Owner: The user who created the file is the owner.
Group: A set of user who is sharing the file and need similar access is a group, or work group.
Universe: All other users in the system constitute the universe.
Access Lists and Groups
The most common approach to the protection problem is to make access dependent on the
identity of the user. Various users may need different identity-dependent access is to associate with
each file and directory an Access-Control List (ACL)
 Mode of access: read, write, execute
 Three classes of users
1133..33 KKeerrnneell II//OO SSuubbssyysstteemm
OPERATING SYSTEMS
v-9
 RWX
 a) owner access 7  1 1 1
RWX
 b) group access 6  1 1 0
 RWX
 c) public access 1  0 0 1
 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.
5. Device allocation
 Some operating systems provide support for exclusive device access, by enabling a process
to allocate an idle device and to deallocate that device open file handle to such a device.
 Many operating systems provide functions that enable processes to coordinate exclusive
access among them.
 For example, Windows NT provides system calls to wait until a device object becomes
available.
 It has a parameter to the open () system call that declares the types of access to be
permitted to other concurrent thread.
6. Buffering:
A buffer is a memory area that stores data while they are transferred between two devices or
between a device and an application. Buffering is done for three reasons.
OPERATING SYSTEMS
v-10
The three reasons are given below
1. It is to cope with a speed mismatch between the producer and consumer of a data stream
Example:
A file is being received via modem for storage on the hard disk. The modem is about a thousand
times slower than the hard disk. So a buffer is created in main memory to accumulate the bytes
received form the modem.
When an entire buffer of data has arrived, the buffer can be written to disk in a single operation.
The modem needs the two buffers to store additional incoming data, two buffers are used.
After the modem fills the first buffer, the disk write is requested. When the modem the starts to fill
the second buffer while the first buffer is written to disk. By the time the modem has filled the
second buffer, the disk write from the first one should have completed, so the modem can switch
back to the first buffer while disk writes the second one. This is called double buffering.
2. A second use of buffering is to adapt between devices that have different data transfer sizes.
Buffers are used for fragmentation and reassembly of messages. At the sending side, a large
message is fragmented into small network packets. The packets are sent over the network, and the
receiving side places them in a reassembly buffer to form an image of the source data.
3. A third use of buffering is to support copy semantics for application I/O.
Copy semantics:
 An application has a buffer of data that it wishes to write to disk.
 It calls the write () system call, providing a pointer to the buffer and an
integer specifying the number of bytes to write.
 A write() system call to copy the application data into a kernel buffer before
returning control to the application.
 The disk write is performed from the kernel buffer, so that subsequent
changes to the application buffer have no effect.
6.caching
 A cache us a region of fast memory that holds copies of data.
 Access to the cached copy is more efficient than access to the original.
 The instructions of currently running process are stored on disk, cached in physical
memory, and copied again in the CPU’s secondary and primary caches.
OPERATING SYSTEMS
v-11
 The difference between a buffer and cache is that buffer may hold the only existing copy of
data item, whereas a cache holds a copy on faster storage of an item that resides elsewhere.
 To enable efficient scheduling of disk I/O, the operating system uses buffers in main
memory to hold disk data.
 These buffers are also used as a cache, to improve the I/O efficiency for files that are
shared by applications or that are being written and reread.
6.spooling:
 A spool is a buffer that holds output for device, such as printer, that cannot accept
interleaved data streams.
 Although a printer can serve only one job at a time, several applications may wish to print
their output concurrently, without having their output mixed together.
 The operating system solves this problem by intercepting all output to the printer.
 Each application’s output is spooled to separate disk file.
 When an application finishes printing, the spooling system queues the corresponding spool
file for output to the printer.
 The spooling system copies the queued spool files to the printer one at a time.
 The operating system provides a control interface that enables user and system
administrator to display the queue to remove unwanted jobs before those jobs print, to
suspend printing while the printer is serviced.
7.I/O scheduling:
 To schedule a set of I/O requests means to determine a good order in which to execute
them.
 Scheduling can improve overall system performance; can share device access fairly
among process.
 It can reduce the average waiting time for I/O to complete.
Example:
Application 2 requests one near the beginning, and application 3 requests one in the middle of the
disk.
OPERATING SYSTEMS
v-12
The operating system can reduce the distance that the disk arm travels by servicing the applications
in order 2,3,1.
8.Error Handling:
 An operating system protected the memory from the hardware failure and application
errors.
 Devices and I/O transfers can fail in many ways, either for transient reasons, such as
network becoming overloaded, or for the permanent reasons, such as disk controller
becoming defective.
 Operating system can compensate for transient failure. For example, a disk read () failure
results in a read () retry (), and a network send () error results in a resend ().
 I/O system call will return 1 bit of information about the status of the call.
In UNIX operating system an additional integer variable named errno is used to return an
error code-one of about 100 values –indicating the general failure of the failure.
 For example a failure of a SCSI device is reported by the SCSI such as hardware error or
an illegal request and additional sense code that states the category of failure such as bad
command parameter or self test failure and additional sense code qualifier that gives even
more details.
OPERATING SYSTEMS
v-13
 The kernel needs to keep state information about the use of I/O components. It does so
through a variety of in Kernel data structures, such as the Open-file table structure.
 The kernel uses many similar data structures to track network connections, character
communications and other I/O activities.
 UNIX provides file-system to a variety of entities, such as user files raw devices, and the
address spaces of processes.
 Although each of these entities supports a read () operation, the semantics differ.
 For instance, to read a user file, the kernel needs to provide the buffer cache before
deciding whether to perform a disk I/O.
 To read a raw disk, the kernel needs to ensure that the request size is multiple of the disk
sector size, and is aligned on a sector boundary.
 To read a process image, it is merely necessary to copy data from memory.
UUNNIIXX II//OO KKeerrnneell SSttrruuccttuurree
OPERATING SYSTEMS
v-14
 UNIX encapsulates these differences within a uniform structure by using an object-
oriented technique. The open-file record contains a dispatch table the holds pointers to
the appropriate routines, depending on the type of file.
 Some operating systems use object oriented methods even more extensively.
 In Windows NT uses a message-passing implementation for I/O.
 An I/O request is converted into a message that is sent through the kernel to the I/O
manager and the to the device driver, each of which may change the message contents.
 For O/P the message contains the data to be written.
 For I/P the message contains, a buffer to receive the data.
 The message passing simplifies the structure and designs the I/O system and adds
flexibility.
16 marks questions
1. Expalin the kernel I/O subsystem structures
2. Explain the kernel I/O subsystem services
OPERATING SYSTEMS
v-15
14.1 Disk structure
 Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the logical
block is the smallest unit of transfer.
 The 1-dimensional array of logical blocks is mapped into the sectors of the disk
sequentially.
o Sector 0 is the first sector of the first track on the outermost cylinder.
o Mapping proceeds in order through that track, then the rest of the tracks in that
cylinder, and then through the rest of the cylinders from outermost to innermost.
CChhaapptteerr 1144:: MMaassss--SSttoorraaggee SSyysstteemmss
 Disk structure
 Disk scheduling
 Disk management
 Swap-space management
OPERATING SYSTEMS
v-16
1144..22 DDiisskk SScchheedduulliinngg
The operating system is responsible for using hardware efficiently — for the disk drives, this
means having a fast access time and disk bandwidth.
Access time has two major components
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.
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.
DDiisskk SScchheedduulliinngg ((CCoonntt..))
Several algorithms exist to schedule the servicing of disk I/O requests.
We illustrate them with a request queue (0-199).
98, 183, 37, 122, 14, 124, 65, 67
Head pointer 53
OPERATING SYSTEMS
v-17
FFCCFFSS
Illustration shows total head movement of 640 cylinders.
SSSSTTFF
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.
OPERATING SYSTEMS
v-18
SSSSTTFF ((CCoonntt..))
SSCCAANN
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.
Sometimes called the elevator algorithm.
Illustration shows total head movement of 208 cylinders.
OPERATING SYSTEMS
v-19
SSCCAANN ((CCoonntt..))
CC--SSCCAANN
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.
OPERATING SYSTEMS
v-20
CC--SSCCAANN ((CCoonntt..))
CC--LLOOOOKK
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.
CC--LLOOOOKK ((CCoonntt..))
OPERATING SYSTEMS
v-21
SSeelleeccttiinngg aa DDiisskk--SScchheedduulliinngg AAllggoorriitthhmm
SSTF is common and has a natural appeal
SCAN and C-SCAN perform better for systems that place a heavy load on the disk.
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.
Either SSTF or LOOK is a reasonable choice for the default algorithm.
1144..33 DDiisskk MMaannaaggeemmeenntt
1. Disk initialization
2. Booting from disk
3. Bad –block recovery
Disk formatting:
A new magnetic disk is a blank slate. Before a disk can store data; it must be divided into
sectors that the controller can read and write.
This process is called low-level formatting (or physical formatting)
Low level formatting:
It fills the disk with special data structure for each sector.
The data structure for a sector typically consists of a header, a data area and a trailer (512 bytes)
The header and trailer contain information used by the disk controller, such as a sector number and
an error code (ECC)
When the controller writes a sector of data during normal I/O, The ECC is updated with value
calculated from all the bytes in the data area. When the sector is read, the ECC is recalculated and
is compared with the stored value .If the stored and calculated numbers are different, this mismatch
indicates that the data area of the sector has become corrupted and the disk sector may be bad.
OPERATING SYSTEMS
v-22
Logical formatting:
To use a disk to hold files, the operating system needs to record its own data structures on
the disk.
It does so in two steps
1. It partitioned the disk into one or more groups of cylinders. The operating system
can treat each partition as though it were a separate disk.
One partition can hold a copy of the operating system executable code.
Another holds user files.
2. The second step is logical formatting the operating system stores the initial file
system data structures onto the disk
MS-DOS DISK LAYOUT
Boot Block:
 When the system is powered up or rebooted, it needs to have an initial program to run.
 This initial bootstrap program tends to be simple. It initializes all aspects of the system
form CPU registers to device controllers and the contents of main memory and then
starts the operating system
 Bootstrap program finds the operating system kernel on disk Loads the kernel into
memory and jumps to an initial address to begin the operating system executing.
 Bootstrap is stored in read-only memory(ROM).This location is convenient, because
ROM needs no initialization and is at a fixed location that the processor can start
executing when powered up or reset.
BOOT BLOCK
FAT
ROOT DIRECTORY
DATA BLOCKS
(SUB DIRECTORIES)
OPERATING SYSTEMS
v-23
 The problem is that changing this bootstrap code requires changing the ROM hardware
chips.
 The full bootstrap program can be changed easily.
 The full bootstrap program is stored in a partition called the boot blocks, at a fixed
location on data.
 A disk that has a boot partition is called a boot disk or system disk.
Bad blocks(one or more sectors become define)
 The MS_DOS format command does a logical sometime the failure is completed and the
disk needs to be replaced and its contents restored from backup media to the new disk.
 MS-DOS format command does a logical format and operating system a part of the
process, scan the disk to find bad blocks. If format finds a bad block ,it writes a special
value into the corresponding FAT entry to tell the allocation routines not to use that
block.(chkdsk) must be run manually to search for the bad block is data that resided on the
bad block usually are lost.
 The controller can be told to replace each bad sector logically with one of the spare sectors.
This scheme is known as sector sparing or forwarding.
Example
 A typical bad-sector transaction might be as follows .The Operating system tries to read
logical block 87
 The controlled calculates the ECC and finds that the sector is bad .It reports this finding
the operating system
 The next time that the system is rebooted, a special command is run to tell the SCSI
controller to replace the bad sector with a spare.
 After that whenever the system requests logical block 87, the request is translated into
the replacement sectors address by the controller.
Some controllers can be instructed to replace a bad block by sector slipping.
OPERATING SYSTEMS
v-24
Logical block 17 becomes defective and the first available spare follows sector 202, then
sector slipping would remap all the sectors form 17 to 202.
14.4 Swap-space management:
Low levels task operating system
 How swap space is used
 Where swap space is located on disk
 How swap space is managed
Swap space use:
Implementing swapping may use swap space to hold the entire process image including the
code and data segments.
Swap space location:
Two places
 Out of the normal system
 It can be in separate disk partition
Swap space Management:
Enough space is aside to hold the program known as the text pages or the text segment and
the data segment of the process.
Swap Maps:
Two process swap maps are used by the kernel to track swap space use .The test segment is a fixed
size.
OPERATING SYSTEMS
v-25
The text segment is a fixed size, so its swap space is allocated in 512 kB chunks, except for the
final chunk, which holds the remainder of the page
The data segment:
Swap map is more complicated because that data segment can grow over time .The map is of fixed
size, but contains swap address for blocks of varying size. Given index i a block pointed to by
swap-map entry I is of size 2*16 KB to maximum of 2MB.
16 marks questions
1. Explain disk scheduling algorithms
2. Suppose that disk drive has 5,000 cylinders, numbers to 0 to 4000.The drive is currently serving
a request at cylinder 143 and the previous request was at cylinders 125.The queue of pending
requests in FIFO order is
86,1470,913,1774,1509,1022,1750,130.
Starting from the current head position what is the total distance that the disk arm moves to satisfy
all the pending requests for each of the following disk-scheduling algorithms?
 FCFS,SSTF
 SCAN
 LOOK
 C-SCAN ,C-LOOK
3. Explain disk structure with diagram
4. Explain swap space management
5. Explain disk management
******************

More Related Content

PPTX
Storage Structure in OS
PPT
DOCX
Operating System Structure (documentation)
PPTX
Operating System Case Study and I/O System
PDF
02.Os Structure
PPT
Chapter 2 - Operating System Structures
PPT
Chapter 13 - I/O Systems
PPT
Structure of operating system
Storage Structure in OS
Operating System Structure (documentation)
Operating System Case Study and I/O System
02.Os Structure
Chapter 2 - Operating System Structures
Chapter 13 - I/O Systems
Structure of operating system

What's hot (20)

PPT
Secondary storage structure-Operating System Concepts
PPTX
I/O System and Case study
PPT
OS - Ch2
PPTX
Storage management in operating system
PPT
PPT
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
PDF
CS6401 Operating Systems
PPTX
Structure of operating system
PDF
Operating system concepts (notes)
PPT
PDF
2 operating system structures
PPTX
Kernel I/O subsystem
PPT
PPTX
I/O System and Case study
PDF
Cs8493 unit 5
PPT
Dheeraj chugh -_presentation_on_ms-dos
PDF
operating system structure
PPT
Dos prompt, types of commands .27 t028
Secondary storage structure-Operating System Concepts
I/O System and Case study
OS - Ch2
Storage management in operating system
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION
CS6401 Operating Systems
Structure of operating system
Operating system concepts (notes)
2 operating system structures
Kernel I/O subsystem
I/O System and Case study
Cs8493 unit 5
Dheeraj chugh -_presentation_on_ms-dos
operating system structure
Dos prompt, types of commands .27 t028
Ad

Viewers also liked (15)

PDF
Fulvestrant extended
PPTX
#TSA2016 New Trends in Talent Acquisition by Jonathan Kestenbaum, Talent Tech...
DOCX
Diploma0001
PDF
Technology and Religion
PDF
OpenNTF – Because Opensource is Collaboration at its best and matters!
PPTX
Cómo subir documentos a drive y compartirlos
PPTX
linea AV/AC - Treviglio Brescia
PDF
RFI - 1° Forum Nazionale sulla Portualità e la Logistica - Lo stato di attuaz...
PDF
Indicatori di puntualità per il trasporto regionale Trenitalia - 1° semestre ...
PPTX
詹姆士看天下 2017/01/09
PPTX
Humanising Cognitive Systems
PDF
Descripción archivística normalizada y normas ISAD(G) e ISAAR(CPF)
PPT
Consulting MSDS
PPTX
Cuestionario a adultos mayores.
Fulvestrant extended
#TSA2016 New Trends in Talent Acquisition by Jonathan Kestenbaum, Talent Tech...
Diploma0001
Technology and Religion
OpenNTF – Because Opensource is Collaboration at its best and matters!
Cómo subir documentos a drive y compartirlos
linea AV/AC - Treviglio Brescia
RFI - 1° Forum Nazionale sulla Portualità e la Logistica - Lo stato di attuaz...
Indicatori di puntualità per il trasporto regionale Trenitalia - 1° semestre ...
詹姆士看天下 2017/01/09
Humanising Cognitive Systems
Descripción archivística normalizada y normas ISAD(G) e ISAAR(CPF)
Consulting MSDS
Cuestionario a adultos mayores.
Ad

Similar to Unit vos - File systems (20)

PPTX
KERNEL_I[1].pptxhbffffgbbbbbggg ffffvbbbhhhm
PDF
CH01.pdf
PPTX
Operating system (BCS303) MODULE 1 NOTES
PDF
Unit 6
PPT
Operating system notes ch1
PPT
PPTX
Operating Systems- Dr.G.Sumathi AI & DS, KNCET
PDF
Cs8493 unit 1
PPT
Operating systems structures and their practical applications
PPT
Operating systems. replace ch1 with numbers for next chapters
PPT
OS - Ch1
PPT
Chapter 1 - Introduction
PPT
ch2 - computer system unit 32 structures.ppt
PPT
PPT
OS Intro.ppt
PPT
OPERATING SYSTEM ENGINEERING SYLLABUS PPT
PPT
Basics of Operating System
PPT
operating system over view.ppt operating sysyems
PPT
Os structure
PPTX
381CCS_CHAPTER1_UPDATEDdatabase management .pptx
KERNEL_I[1].pptxhbffffgbbbbbggg ffffvbbbhhhm
CH01.pdf
Operating system (BCS303) MODULE 1 NOTES
Unit 6
Operating system notes ch1
Operating Systems- Dr.G.Sumathi AI & DS, KNCET
Cs8493 unit 1
Operating systems structures and their practical applications
Operating systems. replace ch1 with numbers for next chapters
OS - Ch1
Chapter 1 - Introduction
ch2 - computer system unit 32 structures.ppt
OS Intro.ppt
OPERATING SYSTEM ENGINEERING SYLLABUS PPT
Basics of Operating System
operating system over view.ppt operating sysyems
Os structure
381CCS_CHAPTER1_UPDATEDdatabase management .pptx

More from donny101 (9)

PPTX
Unit v
PPTX
Unit iv
PPTX
Unit iii
PPTX
Unit ii
PPTX
Unit 1
PDF
Unit ivos - file systems
PDF
Unit iios process scheduling and synchronization
PDF
Unit iiios Storage Management
PDF
Unit 1os processes and threads
Unit v
Unit iv
Unit iii
Unit ii
Unit 1
Unit ivos - file systems
Unit iios process scheduling and synchronization
Unit iiios Storage Management
Unit 1os processes and threads

Recently uploaded (20)

PDF
Well-logging-methods_new................
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPT
Mechanical Engineering MATERIALS Selection
PDF
composite construction of structures.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Welding lecture in detail for understanding
PPTX
Construction Project Organization Group 2.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Well-logging-methods_new................
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Arduino robotics embedded978-1-4302-3184-4.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Mechanical Engineering MATERIALS Selection
composite construction of structures.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Internet of Things (IOT) - A guide to understanding
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Welding lecture in detail for understanding
Construction Project Organization Group 2.pptx
bas. eng. economics group 4 presentation 1.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
CYBER-CRIMES AND SECURITY A guide to understanding
UNIT 4 Total Quality Management .pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...

Unit vos - File systems

  • 2. OPERATING SYSTEMS v-2 Kernel I/O Subsystem  Scheduling o Some I/O request ordering via per-device queue o Some OSs try fairness  Buffering - store data in memory while transferring between devices o To cope with device speed mismatch o To cope with device transfer size mismatch o To maintain “copy semantics” Device-status Table Sun Enterprise 6000 Device-Transfer Rates
  • 3. OPERATING SYSTEMS v-3  Caching - fast memory holding copy of data o Always just a copy o Key to performance  Spooling - hold output for a device o If device can serve only one request at a time o i.e., Printing  Device reservation - provides exclusive access to a device o System calls for allocation and deallocation o Watch out for deadlock Error Handling  OS can recover from disk read, device unavailable, transient write failures  Most return an error number or code when I/O request fails  System error logs hold problem reports I/O Protection  User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions o All I/O instructions defined to be privileged o I/O must be performed via system calls  Memory-mapped and I/O port memory locations must be protected too
  • 4. OPERATING SYSTEMS v-4 Use of a System Call to Perform I/O Kernel Data Structures  Kernel keeps state info for I/O components, including open file tables, network connections, character device state  Many, many complex data structures to track buffers, memory allocation, “dirty” blocks  Some use object-oriented methods and message passing to implement I/O UNIX I/O Kernel Structure
  • 5. OPERATING SYSTEMS v-5 I/O Requests to Hardware Operations  Consider reading a file from disk for a process: o Determine device holding file o Translate name to device representation o Physically read data from disk into buffer o Make data available to requesting process o Return control to process Life Cycle of an I/O Request 13.4 STREAMS  STREAM – a full-duplex communication channel between a user-level process and a device in Unix System V and beyond  A STREAM consists of: - STREAM head interfaces with the user process - driver end interfaces with the device - zero or more STREAM modules between them.  Each module contains a read queue and a write queue
  • 6. OPERATING SYSTEMS v-6  Message passing is used to communicate between queues The STREAMS Structure 13.5 Performance  I/O a major factor in system performance: o Demands CPU to execute device driver, kernel I/O code o Context switches due to interrupts o Data copying o Network traffic especially stressful Intercomputer Communications
  • 7. OPERATING SYSTEMS v-7 Improving Performance  Reduce number of context switches  Reduce data copying  Reduce interrupts by using large transfers, smart controllers, polling  Use DMA  Balance CPU, memory, bus, and I/O performance for highest throughput Device-Functionality Progression
  • 8. OPERATING SYSTEMS v-8 Kernels provide many services related to I/O. Several services are given below 1. The management of the name space for file and devices 2. Access control to files and devices 3. Operation control (for example, a modem cannot seek ()) 4. File System space allocation 5. Device allocation 6. Buffering, caching, and spooling 7. I/O scheduling 8. Device status monitoring, error handling and failure recovery 9. Device driver configuration and initialization 1. Access control to files and device Owner: The user who created the file is the owner. Group: A set of user who is sharing the file and need similar access is a group, or work group. Universe: All other users in the system constitute the universe. Access Lists and Groups The most common approach to the protection problem is to make access dependent on the identity of the user. Various users may need different identity-dependent access is to associate with each file and directory an Access-Control List (ACL)  Mode of access: read, write, execute  Three classes of users 1133..33 KKeerrnneell II//OO SSuubbssyysstteemm
  • 9. OPERATING SYSTEMS v-9  RWX  a) owner access 7  1 1 1 RWX  b) group access 6  1 1 0  RWX  c) public access 1  0 0 1  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. 5. Device allocation  Some operating systems provide support for exclusive device access, by enabling a process to allocate an idle device and to deallocate that device open file handle to such a device.  Many operating systems provide functions that enable processes to coordinate exclusive access among them.  For example, Windows NT provides system calls to wait until a device object becomes available.  It has a parameter to the open () system call that declares the types of access to be permitted to other concurrent thread. 6. Buffering: A buffer is a memory area that stores data while they are transferred between two devices or between a device and an application. Buffering is done for three reasons.
  • 10. OPERATING SYSTEMS v-10 The three reasons are given below 1. It is to cope with a speed mismatch between the producer and consumer of a data stream Example: A file is being received via modem for storage on the hard disk. The modem is about a thousand times slower than the hard disk. So a buffer is created in main memory to accumulate the bytes received form the modem. When an entire buffer of data has arrived, the buffer can be written to disk in a single operation. The modem needs the two buffers to store additional incoming data, two buffers are used. After the modem fills the first buffer, the disk write is requested. When the modem the starts to fill the second buffer while the first buffer is written to disk. By the time the modem has filled the second buffer, the disk write from the first one should have completed, so the modem can switch back to the first buffer while disk writes the second one. This is called double buffering. 2. A second use of buffering is to adapt between devices that have different data transfer sizes. Buffers are used for fragmentation and reassembly of messages. At the sending side, a large message is fragmented into small network packets. The packets are sent over the network, and the receiving side places them in a reassembly buffer to form an image of the source data. 3. A third use of buffering is to support copy semantics for application I/O. Copy semantics:  An application has a buffer of data that it wishes to write to disk.  It calls the write () system call, providing a pointer to the buffer and an integer specifying the number of bytes to write.  A write() system call to copy the application data into a kernel buffer before returning control to the application.  The disk write is performed from the kernel buffer, so that subsequent changes to the application buffer have no effect. 6.caching  A cache us a region of fast memory that holds copies of data.  Access to the cached copy is more efficient than access to the original.  The instructions of currently running process are stored on disk, cached in physical memory, and copied again in the CPU’s secondary and primary caches.
  • 11. OPERATING SYSTEMS v-11  The difference between a buffer and cache is that buffer may hold the only existing copy of data item, whereas a cache holds a copy on faster storage of an item that resides elsewhere.  To enable efficient scheduling of disk I/O, the operating system uses buffers in main memory to hold disk data.  These buffers are also used as a cache, to improve the I/O efficiency for files that are shared by applications or that are being written and reread. 6.spooling:  A spool is a buffer that holds output for device, such as printer, that cannot accept interleaved data streams.  Although a printer can serve only one job at a time, several applications may wish to print their output concurrently, without having their output mixed together.  The operating system solves this problem by intercepting all output to the printer.  Each application’s output is spooled to separate disk file.  When an application finishes printing, the spooling system queues the corresponding spool file for output to the printer.  The spooling system copies the queued spool files to the printer one at a time.  The operating system provides a control interface that enables user and system administrator to display the queue to remove unwanted jobs before those jobs print, to suspend printing while the printer is serviced. 7.I/O scheduling:  To schedule a set of I/O requests means to determine a good order in which to execute them.  Scheduling can improve overall system performance; can share device access fairly among process.  It can reduce the average waiting time for I/O to complete. Example: Application 2 requests one near the beginning, and application 3 requests one in the middle of the disk.
  • 12. OPERATING SYSTEMS v-12 The operating system can reduce the distance that the disk arm travels by servicing the applications in order 2,3,1. 8.Error Handling:  An operating system protected the memory from the hardware failure and application errors.  Devices and I/O transfers can fail in many ways, either for transient reasons, such as network becoming overloaded, or for the permanent reasons, such as disk controller becoming defective.  Operating system can compensate for transient failure. For example, a disk read () failure results in a read () retry (), and a network send () error results in a resend ().  I/O system call will return 1 bit of information about the status of the call. In UNIX operating system an additional integer variable named errno is used to return an error code-one of about 100 values –indicating the general failure of the failure.  For example a failure of a SCSI device is reported by the SCSI such as hardware error or an illegal request and additional sense code that states the category of failure such as bad command parameter or self test failure and additional sense code qualifier that gives even more details.
  • 13. OPERATING SYSTEMS v-13  The kernel needs to keep state information about the use of I/O components. It does so through a variety of in Kernel data structures, such as the Open-file table structure.  The kernel uses many similar data structures to track network connections, character communications and other I/O activities.  UNIX provides file-system to a variety of entities, such as user files raw devices, and the address spaces of processes.  Although each of these entities supports a read () operation, the semantics differ.  For instance, to read a user file, the kernel needs to provide the buffer cache before deciding whether to perform a disk I/O.  To read a raw disk, the kernel needs to ensure that the request size is multiple of the disk sector size, and is aligned on a sector boundary.  To read a process image, it is merely necessary to copy data from memory. UUNNIIXX II//OO KKeerrnneell SSttrruuccttuurree
  • 14. OPERATING SYSTEMS v-14  UNIX encapsulates these differences within a uniform structure by using an object- oriented technique. The open-file record contains a dispatch table the holds pointers to the appropriate routines, depending on the type of file.  Some operating systems use object oriented methods even more extensively.  In Windows NT uses a message-passing implementation for I/O.  An I/O request is converted into a message that is sent through the kernel to the I/O manager and the to the device driver, each of which may change the message contents.  For O/P the message contains the data to be written.  For I/P the message contains, a buffer to receive the data.  The message passing simplifies the structure and designs the I/O system and adds flexibility. 16 marks questions 1. Expalin the kernel I/O subsystem structures 2. Explain the kernel I/O subsystem services
  • 15. OPERATING SYSTEMS v-15 14.1 Disk structure  Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer.  The 1-dimensional array of logical blocks is mapped into the sectors of the disk sequentially. o Sector 0 is the first sector of the first track on the outermost cylinder. o Mapping proceeds in order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost. CChhaapptteerr 1144:: MMaassss--SSttoorraaggee SSyysstteemmss  Disk structure  Disk scheduling  Disk management  Swap-space management
  • 16. OPERATING SYSTEMS v-16 1144..22 DDiisskk SScchheedduulliinngg The operating system is responsible for using hardware efficiently — for the disk drives, this means having a fast access time and disk bandwidth. Access time has two major components 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. 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. DDiisskk SScchheedduulliinngg ((CCoonntt..)) Several algorithms exist to schedule the servicing of disk I/O requests. We illustrate them with a request queue (0-199). 98, 183, 37, 122, 14, 124, 65, 67 Head pointer 53
  • 17. OPERATING SYSTEMS v-17 FFCCFFSS Illustration shows total head movement of 640 cylinders. SSSSTTFF 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.
  • 18. OPERATING SYSTEMS v-18 SSSSTTFF ((CCoonntt..)) SSCCAANN 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. Sometimes called the elevator algorithm. Illustration shows total head movement of 208 cylinders.
  • 19. OPERATING SYSTEMS v-19 SSCCAANN ((CCoonntt..)) CC--SSCCAANN 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.
  • 20. OPERATING SYSTEMS v-20 CC--SSCCAANN ((CCoonntt..)) CC--LLOOOOKK 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. CC--LLOOOOKK ((CCoonntt..))
  • 21. OPERATING SYSTEMS v-21 SSeelleeccttiinngg aa DDiisskk--SScchheedduulliinngg AAllggoorriitthhmm SSTF is common and has a natural appeal SCAN and C-SCAN perform better for systems that place a heavy load on the disk. 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. Either SSTF or LOOK is a reasonable choice for the default algorithm. 1144..33 DDiisskk MMaannaaggeemmeenntt 1. Disk initialization 2. Booting from disk 3. Bad –block recovery Disk formatting: A new magnetic disk is a blank slate. Before a disk can store data; it must be divided into sectors that the controller can read and write. This process is called low-level formatting (or physical formatting) Low level formatting: It fills the disk with special data structure for each sector. The data structure for a sector typically consists of a header, a data area and a trailer (512 bytes) The header and trailer contain information used by the disk controller, such as a sector number and an error code (ECC) When the controller writes a sector of data during normal I/O, The ECC is updated with value calculated from all the bytes in the data area. When the sector is read, the ECC is recalculated and is compared with the stored value .If the stored and calculated numbers are different, this mismatch indicates that the data area of the sector has become corrupted and the disk sector may be bad.
  • 22. OPERATING SYSTEMS v-22 Logical formatting: To use a disk to hold files, the operating system needs to record its own data structures on the disk. It does so in two steps 1. It partitioned the disk into one or more groups of cylinders. The operating system can treat each partition as though it were a separate disk. One partition can hold a copy of the operating system executable code. Another holds user files. 2. The second step is logical formatting the operating system stores the initial file system data structures onto the disk MS-DOS DISK LAYOUT Boot Block:  When the system is powered up or rebooted, it needs to have an initial program to run.  This initial bootstrap program tends to be simple. It initializes all aspects of the system form CPU registers to device controllers and the contents of main memory and then starts the operating system  Bootstrap program finds the operating system kernel on disk Loads the kernel into memory and jumps to an initial address to begin the operating system executing.  Bootstrap is stored in read-only memory(ROM).This location is convenient, because ROM needs no initialization and is at a fixed location that the processor can start executing when powered up or reset. BOOT BLOCK FAT ROOT DIRECTORY DATA BLOCKS (SUB DIRECTORIES)
  • 23. OPERATING SYSTEMS v-23  The problem is that changing this bootstrap code requires changing the ROM hardware chips.  The full bootstrap program can be changed easily.  The full bootstrap program is stored in a partition called the boot blocks, at a fixed location on data.  A disk that has a boot partition is called a boot disk or system disk. Bad blocks(one or more sectors become define)  The MS_DOS format command does a logical sometime the failure is completed and the disk needs to be replaced and its contents restored from backup media to the new disk.  MS-DOS format command does a logical format and operating system a part of the process, scan the disk to find bad blocks. If format finds a bad block ,it writes a special value into the corresponding FAT entry to tell the allocation routines not to use that block.(chkdsk) must be run manually to search for the bad block is data that resided on the bad block usually are lost.  The controller can be told to replace each bad sector logically with one of the spare sectors. This scheme is known as sector sparing or forwarding. Example  A typical bad-sector transaction might be as follows .The Operating system tries to read logical block 87  The controlled calculates the ECC and finds that the sector is bad .It reports this finding the operating system  The next time that the system is rebooted, a special command is run to tell the SCSI controller to replace the bad sector with a spare.  After that whenever the system requests logical block 87, the request is translated into the replacement sectors address by the controller. Some controllers can be instructed to replace a bad block by sector slipping.
  • 24. OPERATING SYSTEMS v-24 Logical block 17 becomes defective and the first available spare follows sector 202, then sector slipping would remap all the sectors form 17 to 202. 14.4 Swap-space management: Low levels task operating system  How swap space is used  Where swap space is located on disk  How swap space is managed Swap space use: Implementing swapping may use swap space to hold the entire process image including the code and data segments. Swap space location: Two places  Out of the normal system  It can be in separate disk partition Swap space Management: Enough space is aside to hold the program known as the text pages or the text segment and the data segment of the process. Swap Maps: Two process swap maps are used by the kernel to track swap space use .The test segment is a fixed size.
  • 25. OPERATING SYSTEMS v-25 The text segment is a fixed size, so its swap space is allocated in 512 kB chunks, except for the final chunk, which holds the remainder of the page The data segment: Swap map is more complicated because that data segment can grow over time .The map is of fixed size, but contains swap address for blocks of varying size. Given index i a block pointed to by swap-map entry I is of size 2*16 KB to maximum of 2MB. 16 marks questions 1. Explain disk scheduling algorithms 2. Suppose that disk drive has 5,000 cylinders, numbers to 0 to 4000.The drive is currently serving a request at cylinder 143 and the previous request was at cylinders 125.The queue of pending requests in FIFO order is 86,1470,913,1774,1509,1022,1750,130. Starting from the current head position what is the total distance that the disk arm moves to satisfy all the pending requests for each of the following disk-scheduling algorithms?  FCFS,SSTF  SCAN  LOOK  C-SCAN ,C-LOOK 3. Explain disk structure with diagram 4. Explain swap space management 5. Explain disk management ******************