0% found this document useful (0 votes)
21 views

Unit-5 OS BCS-401

Uploaded by

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

Unit-5 OS BCS-401

Uploaded by

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

Operating Systems

(BCS-401)

I/O Management and Disk Scheduling


(UNIT-5)
Course Instructor:
Dr. Sanjeev Kumar
(Asso. Prof., IT Department, KIET, Ghaziabad)
Operating Systems Syllabus (Unit-5)

OPERATING SYSTEMS (KCS-401) (Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
IO Devices/Hardware
 An input/output device, often known as an IO device, is any hardware that allows a human operator or other systems to
interface with a computer.
 Input/output devices, are capable of delivering data (output) to and receiving data from a computer (input).
 An input/output (I/O) device is a piece of hardware that can take, output, or process data.
Input Devices:
 Keyboard Devices
 Pointing Devices
 Composite Devices
 Game Controller
 Visual Devices
 Audio Input Devices
Output Devices:
 Monitor
 Printer
 Speakers
 Projector
 Plotter
 Video Card
 Headphones

OPERATING SYSTEMS (KCS-401) (Dr.


Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Structure
 In modern computers, most of the secondary storage is in the
form of magnetic disks. Hence, knowing the structure of a
magnetic disk is necessary to understand how the data in the
disk is accessed by the computer.

• Disk drives are addressed as large one dimensional arrays of


logical blocks, where the logical block is the smallest unit of
transfer.

• The one-dimensional array of logical blocks is mapped into


the sectors of the disk sequentially.
• A magnetic disk contains several platters.

• Each platter is divided into circular shaped tracks.

• Each track is further divided into sectors.

• “Outer tracks are bigger in size than the inner tracks but they contain
the same number of sectors and have equal storage capacity.”

• Some space of every sector is used for formatting.

• The actual capacity of a sector is less than the given capacity.


Read-Write(R-W) head
- It moves over the rotating hard disk.

- It is this Read-Write head that performs all the


read and write operations on the disk and hence,
position of the R-W head is a major concern.

- To perform a read or write operation on a memory


location, we need to place the R-W head over that
position.
Important Terms:
• Seek time – The time taken by the Read-Write head to
reach the desired track from it’s current position.
• Rotational latency – Time taken by the sector to come
under the Read-Write head.(Average Rotational Latency=
Rotational Latency/2)
• Data transfer time – Time taken to transfer the required
amount of data. It depends upon the rotational speed.
• Controller time – The processing time taken by the
controller.
• Average Access time – seek time + Average Rotational
latency + data transfer time + controller time.
Example:
Q1) Consider a hard disk with:
4 surfaces
64 tracks/surface
128 sectors/track
256 bytes/sector

a) What is the capacity of the hard disk?

Sol: Disk capacity = surfaces * tracks/surface * sectors/track * bytes/sector


Disk capacity = 4 * 64 * 128 * 256 B = 22* 26* 27* 28 B
Disk capacity = 23* 220 B = 8 MB
b) The disk is rotating at 3600 RPM(revolution per minute),
what is the data transfer rate?
Sol:
60 sec -> 3600 rotations
1 sec -> 60 rotations
•Data transfer rate = number of rotations per second * track
capacity * number of surfaces (since 1 R-W head is used for
each surface)
•Track capacity= sector per track*bytes per sector

Data transfer rate = 60 * [128 * 256] * 4 B/sec


= [15/2 ]* 2 *22* 27* 28* 22 B/sec
Data transfer rate = 7.5 MB/sec
c) The disk is rotating at 3600 RPM, what is the average access time?
Assume other timing zero.
Sol:
Average Access time – seek time + Average Rotational latency + data
transfer time + controller time
Since, seek time, controller time and the amount of data to be transferred are
considered to be 0
Therefore, Average Access time = Average rotational delay
•Rotational latency => 60 sec -> 3600 rotations
1 sec -> 60 rotations
•Rotational latency(one rotation) = (1/60) sec = 0.016666 = 16.67 msec.
Avg. Rotational Latency= Rotational Latency/2
= (16.67)/2 = 8.33 msec.
So, Average Access time = 8.33 msec.
Disk Scheduling
• Disk scheduling is done by operating systems to schedule
I/O requests arriving for the disk. Disk scheduling is also
known as I/O scheduling. Disk scheduling is important
because:
• Multiple I/O requests may arrive by different processes
and only one I/O request can be served at a time by the
disk controller. Thus other I/O requests need to wait in the
waiting queue and need to be scheduled.
• Two or more requests may be far from each other so can
result in greater disk arm movement.
• Hard drives are one of the slowest parts of the computer
system and thus need to be accessed in an efficient
manner.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Goal of Disk Scheduling Algorithms

•Minimize
• g Seek Time
•Maximize Throughput
•Minimize Latency
•Fairness
•Efficiency in Resource Utilization

OPERATING SYSTEMS (KCS-401) (Dr.


Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: FCFS Scheduling
• Consider, for example, a disk queue with requests for I/O to blocks
on cylinders
98, 183, 37, 122, 14, 124, 65, 67

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: SSTF Scheduling
• It seems reasonable to service all the requests
close to the current head position before moving
the head far away to service other requests. This
assumption is the basis for the shortest-seek-
time-first (SSTF) algorithm.
• The SSTF algorithm selects the request with the
least seek time from the current head position. In
other words, SSTF chooses the pending request
closest to the current head position.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: SSTF Scheduling
• Total head movement of only 236 cylinders

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: SCAN Scheduling (Elevator Scheduling)
• In the SCAN algorithm, the disk arm starts at one end of
the disk and moves toward the other end, servicing
requests as it reaches each cylinder, until it gets to the
other end of the disk.
• At the other end, the direction of head movement is
reversed, and servicing continues.
• The head continuously scans back and forth across the
disk.
• The SCAN algorithm is sometimes called the elevator
algorithm, since the disk arm behaves just like an elevator
in a building, first servicing all the requests going up and
then reversing to service requests the other way.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: SCAN Scheduling (Elevator Scheduling)

Total head movement = 236 OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: LOOK Scheduling and C-LOOK Scheduling
• Both SCAN and C-SCAN move the disk arm across
the full width of the disk.
• More commonly, the arm goes only as far as the
final request in each direction. Then, it reverses
direction immediately, without going all the way to
the end of the disk.
• Versions of SCAN and C-SCAN that follow this
pattern are called LOOK and C-LOOK scheduling,
because they look for a request before continuing to
move in a given direction
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: LOOK Scheduling
• Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
• Initial head position = 50
• Direction = right (We are moving from left to right)

Total head movement = 291


OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Disk Scheduling: C-LOOK Scheduling

OPERATING SYSTEMS (KCS-401)


Total head movement = 322 (Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
• Consider a disk with 200 tracks and the
queue has random requests from different
processes in the order:
55, 58, 39, 18, 90, 160, 150, 38, 184
Initially arm is at 100. Find the Average Seek
length using FIFO, SSTF, SCAN and C-SCAN
algorithm.
OPERATING SYSTEMS (KCS-401) (Dr.
Sanjeev Kumar , Asso. Prof., IT, KIET)
Solution

OPERATING SYSTEMS (KCS-401) (Dr.


Sanjeev Kumar , Asso. Prof., IT, KIET)
RAID Structure
• Disk drives have continued to get smaller and cheaper, so it is
now economically feasible to attach many disks to a computer
system.
• Having a large number of disks in a system presents
opportunities for improving the rate at which data can be read
or written, if the disks are operated in parallel.
• Furthermore, this setup offers the potential for improving the
reliability of data storage, because redundant information can
be stored on multiple disks.
• Thus, failure of one disk does not lead to loss of data.
• A variety of disk organization techniques, collectively called
redundant arrays of independent disks (RAID), are commonly
used to address the performance and reliability issues.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Main Concept:
• Disk mirroring or Disk striping.

• Mirroring will copy identical data onto more


than one drive.

• Striping partitions helps spread data over


multiple disk drives.
RAID Levels
• Mirroring provides high reliability, but it is expensive.
• Striping provides high data-transfer rates, but it does not
improve reliability. "striping" refers to the technique of
distributing data across multiple disk drives. Striping
involves breaking down the data into smaller segments,
and writing these stripes sequentially across a set of disks.
• Striping is primarily used to improve performance by
enabling parallel access to data.
• Numerous schemes to provide redundancy at lower cost
by using disk striping combined with “parity” bits.
• These schemes have different cost–performance trade-offs
and are classified according to levels called RAID levels.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
RAID Level 0

• RAID level 0. RAID level 0 refers to disk arrays with striping at the level of
blocks but without any redundancy (such as mirroring or parity bits)
• RAID Level 0 does not include redundancy to improve performance.
• It gives better performance through parallel accesses.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
RAID Level 1
• RAID level 1. RAID level 1 refers to disk mirroring. By
duplicating the full content of one disk in other.
• This configuration increases the probability of
availability
• of data.
• Expensive.
• No data loss if either drive fails.
• Good read performance.
• Reasonable write performance.
• Cost / MB is high. OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
RAID 1+0 or 10
• In this case we combine both previous
approaches.
• Striping as well as mirroring is done.

OPERATING SYSTEMS (KCS-401) (Dr.


Sanjeev Kumar , Asso. Prof., IT, KIET)
RAID 10
Advantages

• Highly fault tolerant

• High data availability

• Very good read / write performance

Disadvantages

• Very expensive

Applications

• Where high performance and redundancy are critical


RAID Level 2
• This uses bit level striping. i.e Instead of
striping the blocks across the disks, it stripes
the bits across the disks.
• One group of disks are used to write the data,
another group is used to write the error
correction codes.
RAID Level 3
• This uses byte level striping. i.e Instead of striping the blocks
across the disks, it stripes the bytes across the disks.

• In the diagram B1, B2, B3 are bytes. p1, p2, p3 are parities.

• Uses multiple data disks, and a dedicated disk to store parity.


• Single disk used to store the parity bit
• Bottleneck come in parity disk.
RAID Level 4
• This uses block level striping.
• In the above diagram B1, B2, B3 are blocks.
p1, p2, p3 are parities.
• Uses multiple data disks, and a dedicated disk
to store parity.
• The performance is very good.
RAID Level 5
• Organised in similar fashion to RAID 4.

• Difference is that RAID 5 describes the parity


strips across all disks.

• Typical allocation is round robin scheme.


RAID 6
• Just like RAID 5, this does block level striping.
However, it uses dual parity.
• In the above diagram A, B, C are blocks. p1, p2,
p3 are parities.
• This creates two parity blocks for each data block.
• Can handle two disk failure.
• This RAID configuration is complex to
implement in a RAID controller, as it has to
calculate two parity data for each data block.
File System
• The file system is the most visible aspect of an operating
system.
• File system module of OS manages all the files on system
i.e. how data will be stored and fetched.
• Every data which is stored on computer disk is file and
managed through file system module of OS kernel.
• It provides the mechanism for on-line storage of and
access to both data and programs of the operating system
and all the users of the computer system.
• The file system consists of two distinct parts: a collection
of files, each storing related data, and a directory
structure, which organizes and provides information about
all the files in the system.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Concept
• A file is a named collection of related information that is
recorded on secondary storage.
• From a user’s perspective, a file is the smallest allotment of
logical secondary storage; that is, data cannot be written to
secondary storage unless they are within a file. Commonly, files
represent programs (both source and object forms) and data.
• Data files may be numeric, alphabetic, alphanumeric, or binary.
Files may be free form, such as text files, or may be formatted
rigidly.
• In general, a file is a sequence of bits, bytes, lines, or records,
the meaning of which is defined by the file’s creator and user.
The concept of a file is thus extremely general.
• Every file is logically divided into blocks and blocks stored on
sectors. File system stores the mapping of the blocks where
they are stored in sectors. OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Attributes
A file’s attributes vary from one operating system to another but typically
consist of these:
• Name. The symbolic file name is the only information kept in human readable
form.
• Identifier. This unique tag, usually a number, identifies the file within the file
system; it is the non-human-readable name for the file.
• Type. This information is needed for systems that support different types of
files.
• Location. This information is a pointer to a device and to the location of the file
on that device.
• Size. The current size of the file (in bytes, words, or blocks) and possibly the
maximum allowed size are included in this attribute.
• Protection. Access-control information determines who can do reading,
writing, executing, and so on.
• Time, date, and user identification. This information may be kept for creation,
last modification, and last use. These data can be useful for protection,
security, and usage monitoring.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Operations
Following are six basic file operations;
• Creating a file
• Writing a file
• Reading a file
• Repositioning within a file
• Deleting a file
• Truncating a file

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Open File Table
• Most of the file operations mentioned involve searching
the directory for the entry associated with the named file.
• To avoid this constant searching, many systems require
that an open() system call be made before a file is first
used.
• The operating system keeps a table, called the open file
table, containing information about all open files. When a
file operation is requested, the file is specified via an index
into this table, so no searching is required.
• When the file is no longer being actively used, it is closed
by the process, and the operating system removes its entry
from the open-file table.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File System: Few Important Concepts
• open() and close() operations
• The open() call can also accept access mode
information—create, read-only, read–write,
append-only, and so on.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Information… associated with an open file
• File pointer
• File-open count
• Disk location of the file
• Access rights

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Types

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Access Methods
• Files store information. When it is used, this
information must be accessed and read into
computer memory. The information in the file
can be accessed following ways;
1. Sequential Access
2. Direct Access
3. Index sequential method
4. Other Access Methods
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Sequential Access
• The simplest access method is sequential access.
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, editors and compilers usually access
files in this fashion.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
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.
• 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.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
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.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Directory and Disk Structure
• Files are stored on random-access storage devices,
including hard disks, optical disks, and solid-state
(memory-based) disks.
• A disk can be partitioned into quarters, and each quarter
can hold a separate file system.
• A file system can be created on each of these parts of the
disk. Any entity containing a file system is generally known
as a volume.
• A volume is a named logical area of the physical disk. It
serves as a type of container for the file system and
provides a structure for accessing data. In this sense, a
volume can be thought of as a logical disk, rather than the
physical disk itself.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Operations on a Directory
• Search for a file
• Create a file
• Delete a file
• List a directory
• Rename a file
• Traverse the file system

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Logical Structure of a Directory
Single-Level Directory
• The simplest directory structure is the single level directory. All files are contained in the
same directory, which is easy to support and understand
• Limitations: however, when the number of files increases or when the system has more
than one user. Since all files are in the same directory, they must have unique names.

• Older version of MS-DOS used this structure.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Logical Structure of a Directory
Two-Level Directory

Early Version Unix systems( Version 6)


e.g. /usr/john
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Logical Structure of a Directory
Two-Level Directory (Disadvantages)
• Although the two-level directory structure solves the
name-collision problem, it still has disadvantages.
• This structure effectively isolates one user from
another.
• Isolation is an advantage when the users are
completely independent but is a disadvantage when
the users want to cooperate on some task and to
access one another’s files.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Logical Structure of a Directory
Tree Structure Directory

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Logical Structure of a Directory
Acyclic-Graph Directories

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Logical Structure of a Directory
General Graph Directory

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Sharing
• File sharing is the practice of distributing or providing
access to digital files between two or more users or
devices.
• While it is a convenient way to share information and
collaborate on projects, it also comes with risks such as
malware and viruses, data breaches, legal consequences,
and identity theft.
• Protecting files during sharing is essential to ensure
confidentiality, integrity, and availability.
• Encryption, password protection, secure file transfer
protocols, and regularly updating antivirus and anti-
malware software are all important measures that can be
taken to safeguard files.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
FILE SYSTEM PROTECTION AND SECURITY
• Safety from physical damage (the issue of reliability) and
improper access (the issue of protection).
• Protection mechanisms provide controlled access by limiting
the types of file access that can be made. Access is permitted
or denied depending on several factors, one of which is the
type of access requested. Several different types of operations
may be controlled:
• Read. Read from the file.
• Write. Write or rewrite the file.
• Execute. Load the file into memory and execute it.
• Append. Write new information at the end of the file.
• Delete. Delete the file and free its space for possible reuse.
• List. List the name and attributes of the file.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
FILE SYSTEM PROTECTION AND SECURITY
Access Control
• The most common approach to the protection problem is
to make access dependent on the identity of the user.
Different users may need different types of access to a file
or directory.
• Many systems recognize three classifications of users in
connection with each file:
• Owner. The user who created the file is the owner.
• Group. A set of users who are sharing the file and need
similar access is a group, or work group.
• Universe. All other users in the system constitute the
universe.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Access Lists and Groups
• Mode of access: read, write, execute
• Three classes of users on Unix / Linux
RWX
a) owner access 7  111
RWX
b) group access 6  110
RWX
c) public access 1  001

• Ask manager to create a group (unique name), say


G, and add some users to the group.
• For a particular file (say game) or subdirectory,
define an appropriate access.

Attach a group to a file


chgrp G game
Windows 7 Access-Control List Management
I/O Buffering
• The buffer is an area in the main memory used to store or hold
the data temporarily.
• Buffer temporarily stores data transmitted from one place to
another, either between two devices or two applications. The
act of storing data temporarily in the buffer is called buffering
• Purpose of Buffering
– It helps in matching speed between two devices.
– It helps the devices with different sizes of data transfer to get
adapted to each other.
– It also supports copy semantics. This means that once data is placed
in the buffer (through a system call, for instance), any subsequent
access to that data will reflect the state of the data at the time of
the system call.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
I/O Buffering Types
Single Buffer
• In Single Buffering, only one buffer is used to transfer the data between two
devices. The producer produces one block of data into the buffer. After that,
the consumer consumes the buffer. Only when the buffer is empty, the
processor again produces the data.
• Here Producer consumer cannot work together.

IO Devices: Block oriented stores blocks in buffer and then move to user
OPERATING process.
SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Stream oriented stores the data line by line or byte byte and then move user process
I/O Buffering Types
• Double Buffer
• In Double Buffering, two schemes or two buffers are used in the place
of one. In this buffering, the producer produces one buffer while the
consumer consumes another buffer simultaneously.
• So, the consumer not needs to wait for filling the buffer. Double
buffering is also known as buffer swapping.
• Here move and In operations can be performed simultaneously

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
I/O Buffering Types
• Circular Buffer
• When more than two buffers are used, the buffers' collection is called
a circular buffer. Each buffer is being one unit in the circular buffer. The
data transfer rate will increase using the circular buffer rather than the
double buffering.
• It is specifically helpful when we are using streamed I/O or fast
input/output speed.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods
• The main problem is how to allocate space to the
files so that disk space is utilized effectively and
files can be accessed quickly.
• Three major methods of allocating disk space are
in wide use:
– Contiguous Allocation
– Linked Allocation
– Indexed Allocation

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods: Contiguous Allocation
• Contiguous allocation requires that each file
occupy a set of contiguous blocks on the disk.
• Minimum movement of disk head.
• If the file is n blocks long and starts at location b,
then it occupies blocks b, b + 1, b + 2, ..., b + n - 1.
• The directory entry for each file indicates the
address of the starting block and the length of
the area allocated for this file.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods: Contiguous Allocation

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods: Linked Allocation
• Linked allocation solves all problems of contiguous
allocation. With linked allocation, each file is a linked
list of disk blocks; the disk blocks may be scattered
anywhere on the disk.
• The directory contains a pointer to the first and last
blocks of the file.
• The major problem is that it can be used effectively
only for sequential access files.
• Another disadvantage is the space required for the
pointers.
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods: Linked Allocation
Linked allocation solves the
external-fragmentation and
size declaration problems of
contiguous allocation.
However, linked allocation
cannot support efficient direct
access, since the pointers to
the blocks are scattered with
the blocks themselves all over
the disk and must be
retrieved in order.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods: Indexed Allocation
• Indexed allocation solves this problem by
bringing all the pointers together into one
location: the index block.
• Each file has its own index block, which is an
array of disk-block addresses.
• The ith entry in the index block points to the ith
block of the file.

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
File Allocation Methods: Indexed Allocation

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Kernel I/O Subsystem
• I/O Scheduling
• Buffering
• Caching
• Error Handling
• I/O Protection

OPERATING SYSTEMS (KCS-401)


(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Few Important Concepts
• Direct Memory Access (DMA)
• Polling Vs Interrupts
• Access Matrix
• Boot Blocks (primary purpose of a boot block is to contain essential code or instructions that are
necessary to start up the operating system)
• Free Space Management
– Bit Vector: Using a bit vector (or bitmap) to represent allocated and
free blocks of storage. Each bit in the vector corresponds to a block
on the disk, indicating whether the block is in use (allocated) or
available (free).
– Linked List: Maintaining a linked list of free blocks where each block
contains a pointer to the next free block.
– Grouping : Grouping contiguous free blocks together and counting
them to quickly locate and allocate larger chunks of space
OPERATING SYSTEMS (KCS-401)
(Dr. Sanjeev Kumar , Asso. Prof., IT, KIET)
Practice Problem
Consider a disk pack with the following specifications- 16 surfaces, 128
tracks per surface, 256 sectors per track and 512 bytes per sector.
1. What is the capacity of disk pack?
2. What is the number of bits required to address the sector?
3. If the format overhead is 32 bytes per sector, what is the formatted disk
space?
4. If the format overhead is 64 bytes per sector, how much amount of
memory is lost due to formatting?
5. If the diameter of innermost track is 21 cm, what is the maximum
recording density?
6. If the diameter of innermost track is 21 cm with 2 KB/cm, what is the
capacity of one track?
7. If the disk is rotating at 3600 RPM, what is the data transfer rate?
8. If the disk system has rotational speed of 3000 RPM, what is the average
access time with a seek time of 11.5 msec?

OPERATING SYSTEMS (KCS-401) (Dr.


Sanjeev Kumar , Asso. Prof., IT, KIET)
Solution: Given Surfaces=16
tracks/surface=128
Sectors per track= 256
bytes/sector=512
1. Capacity of disk pack
= Total number of surfaces x Number of tracks per surface x Number of sectors per track x Number of bytes
per sector= 16 x 128 x 256 x 512 =256MB
2. Total sectors= surface X tracks per surface X number of sectors per track=16x128x256= 219 so 19 bits
required.
3/4. Formatting overhead= sectors x overhead per sector= 219 x32 bytes=16 MB, so formatted disk space=
256MB-16MB=240MB
5/6. Max. Recording density: bytes per unit length of track
Storage capacity of track= number of sectors per track x Number of bytes per sector= 256 x 512 byte =
217 bytes=128 KB. Circumference of innermost track= 2 pi radius= pi X d= 3.14x21 cm=65.94 cm.
Now max. recording density= capacity of track/circumference of innermost track=128 KB/ 65.94 cm
=1.94 KB/cm
7. Data transfer rate= number of surfaces or heads x capacity of track x number of rotations
=16 x [256x512 bytes] x60=60x 221 = 120 mbps
8. Average access time= average seek time+ average latency+other delays
For rotatation delay= need time for full rotation=60/3000 =1/50 sec=0.02 sec=20ms. So average= ½
*20=10 ms.
So average access time= average seek time+ average latency+other delays+other=11.5+10+0=21.5 ms.
Practice Problem

You might also like