Unit 4 Part 1
Unit 4 Part 1
Unit 4 Part 1
Mass Storage system – Disk Structure - Disk Scheduling and Management; File-System
Interface -
File concept - Access methods - Directory Structure - Directory organization - File system
mounting - File Sharing and Protection;
File System Implementation - File System Structure - Directory implementation - Allocation
Methods - Free Space Management;
I/O Systems – I/O Hardware, Application I/O interface, Kernel I/O subsystem.
Disk Scheduling
1
User-Space I/O Software
outermost cylinder.
Mapping proceeds in order through that track, then the
3
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.
Access time has two major components
Seek time is the time for the disk are to move the
Head pointer 53
8
FCFS
9
SSTF
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.
10
SSTF (Cont.)
11
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.
Sometimes called the elevator algorithm.
Illustration shows total head movement of
208 cylinders.
12
SCAN (Cont.)
13
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.
14
C-SCAN (Cont.)
15
C-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.
16
C-LOOK (Cont.)
17
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.
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.
18
Key topics
1. File attributes
2. File Operations
3. File types
4. File Structure
5. File Internal Structure
File Attributes - NILTIPS
FILE OPERATIONS
1. CREATE
2. READ
3. WRITE
4. REPOSITION
5. DELETE
6. TRUNCATE
INTERNAL FILE STRUCTURE
● Internally, locating an offset within a file can be complicated for the operating system.
● Disk systems typically have a well-defined block size determined by the size of a sector.
● All disk I/O is performed in units of one block (physical record), and all blocks are the same
size. It is unlikely that the physical record size will exactly match the length of the desired
logical record.
● Logical records may even vary in length. Packing a number of logical records into physical
blocks is a common solution to this problem.
● For example, the UNIX operating system defines all files to be simply streams of bytes. Each
byte is individually addressable by its offset from the beginning (or end) of the file. In this
case, the logical record size is 1 byte.
● The file system automatically packs and unpacks bytes into physical disk blocks— say, 512
bytes per block—as necessary.
● The logical record size, physical block size, and packing technique determine how many
logical records are in each physical block.
● The packing can be done either by the user’s application program or by the operating
system.
● THE END
Sequential Access –
It is the simplest access method. Information in the file is processed in order, one record after the
other. This mode of access is by far the most common; for example, editor and compiler usually
access the file in this fashion.
Read and write make up the bulk of the operation on a file. A read operation -read next- read the next
position of the file and automatically advance a file pointer, which keeps track I/O location. Similarly,
for the -write next- append to the end of the file and advance to the newly written material.
.Direct Access –
Another method is direct access method also known as relative access method. A fixed-length logical
record that allows the program to read and write record rapidly. in no particular order. The direct
access is based on the disk model of a file since disk allows random access to any file block. For direct
access, the file is viewed as a numbered sequence of block or record. Thus, we may read block 14
then block 59, and then we can write block 17. There is no restriction on the order of reading and
writing for a direct access file.
A block number provided by the user to the operating system is normally a relative block number, the
first relative block of the file is 0 and then 1 and so on
Index sequential method –
It is the other method of accessing a file that is built on the top of the sequential access method.
These methods construct an index for the file. The index, like an index in the back of a book, contains
the pointer to the various blocks. To find a record in the file, we first search the index, and then by the
help of pointer we access the file directly.
Key points:
● It is built on top of Sequential access.
● It control the pointer by using inde
● THE END
STORAGE STRUCTURE
DIRECTORY OPERATIONS
DIRECTORY STRUCTURE
TREE STRUCTURE DIRECTORY- KEY POINTS
ACYCLIC KEY POINTS
● THE END
File system mounting
● Just as a file must be opened before it is used, a file system must be mounted before it can be available to
processes on the system. More specifically, the directory structure may be built out of multiple volumes, which
must be mounted to make them available within the file-system name space.
● The operating system is given the name of the device and the mount point—the location within the file structure
where the file system is to be attached. Some operating systems require that a file system type be provided, while
others inspect the structures of the device and determine the type of file system. Typically, a mount point is an
empty directory.
● For instance, on a UNIX system, a file system containing a user’s home directories might be mounted as /home;
then, to access the directory structure within that file system, we could precede the directory names with /home, as
in /home/jane
● Next, the operating system verifies that the device contains a valid file system. It does so by asking the device
driver to read the device directory and verifying that the directory has the expected format. Finally, the operating
system notes in its directory structure that a file system is mounted at the specified mount point. This scheme
enables the operating system to traverse its directory structure, switching among file systems, and even file
systems of varying types, as appropriate.
● Systems impose semantics to clarify functionality. For example, a system may disallow a mount over a directory
that contains files; or it may make the mounted file system available at that directory and obscure the directory’s
existing files until the file system is unmounted, terminating the use of the file system and allowing access to the
original files in that directory
● Consider the actions of the Mac OS X operating system. Whenever the system encounters a disk for the first time
(either at boot time or while the system is running), the Mac OS X operating system searches for a file system on
the device. If it finds one, it automatically mounts the file system under the /Volumes directory, adding a folder icon
labeled with the name of the file system (as stored in the device directory). The user is then able to click on the
icon and thus display the newly mounted file system
● THE END
FILE SHARING
● THE END
EXAMPLE