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

Unit 5 (With Page Number)

Uploaded by

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

Unit 5 (With Page Number)

Uploaded by

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

LECTURE 45

I/O Management
I/O Devices
One of the important jobs of an Operating System is to manage various I/O devices including
mouse, keyboards, touch pad, disk drives, display adapters, USB devices, Bit-mapped screen,
LED, Analog-to-digital converter, On/off switch, network connections, audio I/O, printers etc.An
I/O system is required to take an application I/O request and send it to the physical device, then
take whatever response comes back from the device and send it to the application. I/O devices
can be divided into two categories

● Block devices

● Character devices

Device Controllers

Device drivers are software modules that can be plugged into an OS to handle a particular
device. Operating System takes help from device drivers to handle all I/O devices.
The Device Controller works like an interface between a device and a device driver. I/O units
(Keyboard, mouse, printer, etc.) typically consist of a mechanical component and an electronic
component where electronic component is called the device controller.
There is always a device controller and a device driver for each device to communicate with the
Operating Systems. A device controller may be able to handle multiple devices. As an interface
its main task is to convert serial bit stream to block of bytes, perform error correction as
necessary.
Any device connected to the computer is connected by a plug and socket, and the socket is
connected to a device controller. Following is a model for connecting the CPU, memory,
controllers, and I/O devices where CPU and device controllers all use a common bus for
communication.

142
Synchronous vs Asynchronous I/O
● Synchronous I/O

● Asynchronous I/O

Communication to I/O Devices


The CPU must have a way to pass information to and from an I/O device. There are three
approaches available to communicate with the CPU and Device.

● Special Instruction I/O

● Memory-mapped I/O

● Direct memory access (DMA)

Special Instruction I/O


This uses CPU instructions that are specifically made for controlling I/O devices. These
instructions typically allow data to be sent to an I/O device or read from an I/O device.
Memory-mapped I/O
When using memory-mapped I/O, the same address space is shared by memory and I/O devices.
The device is connected directly to certain main memory locations so that I/O device can transfer
block of data to/from memory without going through CPU.

143
While using memory mapped IO, OS allocates buffer in memory and informs I/O device to use
that buffer to send data to the CPU. I/O device operates asynchronously with CPU, interrupts
CPU when finished.
The advantage to this method is that every instruction which can access memory can be used to
manipulate an I/O device. Memory mapped IO is used for most high-speed I/O devices like
disks, communication interfaces.

Direct Memory Access (DMA)


Slow devices like keyboards will generate an interrupt to the main CPU after each byte is
transferred. If a fast device such as a disk generated an interrupt for each byte, the operating
system would spend most of its time handling these interrupts. So a typical computer uses direct
memory access (DMA) hardware to reduce this overhead.
Direct Memory Access (DMA) means CPU grants I/O module authority to read from or write to
memory without involvement. DMA module itself controls exchange of data between main
memory and the I/O device. CPU is only involved at the beginning and end of the transfer and
interrupted only after entire block has been transferred.
Direct Memory Access needs a special hardware called DMA controller (DMAC) that manages
the data transfers and arbitrates access to the system bus. The controllers are programmed with
source and destination pointers (where to read/write the data), counters to track the number of
transferred bytes, and settings, which includes I/O and memory types, interrupts and states for
the CPU cycles.

144
The operating system uses the DMA hardware as follows
Step Description

1 Device driver is instructed to transfer disk data to a buffer address X.

2 Device driver then instruct disk controller to transfer data to buffer.

3 Disk controller starts DMA transfer.

4 Disk controller sends each byte to DMA controller.

DMA controller transfers bytes to buffer, increases the memory address,


5
decreases the counter C until C becomes zero.

6 When C becomes zero, DMA interrupts CPU to signal transfer completion.

Polling vs Interrupts I/O

A computer must have a way of detecting the arrival of any type of input. There are two ways
that this can happen, known as polling and interrupts. Both of these techniques allow the
processor to deal with events that can happen at any time and that are not related to the process it
is currently running.

Polling I/O-
Polling is the simplest way for an I/O device to communicate with the processor. The process of
periodically checking status of the device to see if it is time for the next I/O operation, is called
145
polling. The I/O device simply puts the information in a Status register, and the processor must
come and get the information.
Most of the time, devices will not require attention and when one does it will have to wait until it
is next interrogated by the polling program. This is an inefficient method and much of the
processors time is wasted on unnecessary polls.
Compare this method to a teacher continually asking every student in a class, one after another, if
they need help. Obviously the more efficient method would be for a student to inform the teacher
whenever they require assistance.
Interrupt I/O-
An alternative scheme for dealing with I/O is the interrupt-driven method. An interrupt is a
signal to the microprocessor from a device that requires attention.
A device controller puts an interrupt signal on the bus when it needs CPU’s attention when CPU
receives an interrupt, It saves its current state and invokes the appropriate interrupt handler using
the interrupt vector (addresses of OS routines to handle various events). When the interrupting
device has been dealt with, the CPU continues with its original task as if it had never been
interrupted.

LECTURE 46
I/O Subsystems
Kernel I/O Subsystem in Operating System

The kernel provides many services related to I/O. Several services such as scheduling, caching,
spooling, device reservation, and error handling – are provided by the kernel’s I/O subsystem
built on the hardware and device-driver infrastructure. The I/O subsystem is also responsible for
protecting itself from errant processes and malicious users.

1. I/O Scheduling –
To schedule a set of I/O requests means to determine a good order in which to execute
them. The order in which the application issues the system call is the best choice.
Scheduling can improve the overall performance of the system, can share device access
permission fairly to all the processes, and reduce the average waiting time, response time,
and turnaround time for I/O to complete. OS developers implement schedules by
maintaining a wait queue of the request for each device. When an application issues a
blocking I/O system call, The request is placed in the queue for that device. The I/O
scheduler rearranges the order to improve the efficiency of the system.

2. Buffering –
A buffer is a memory area that stores data being transferred between two devices or
between a device and an application. Buffering is done for three reasons.

146
The first is to cope with a speed mismatch between the producer and consumer of a data
stream.
2. The second use of buffering is to provide adaptation for data that have different data-
transfer sizes.
3. The third use of buffering is to support copy semantics for the application I/O, “copy
semantic” means, suppose that an application wants to write data on a disk that is stored
in its buffer. It calls the write () system’s call, providing a pointer to the buffer and the
integer specifying the number of bytes to write.

3. Caching –
A cache is a region of fast memory that holds a copy of data. Access to the cached copy
is much easier than the original file. For instance, the instruction of the currently running
process is stored on the disk, cached in physical memory, and copied again in the CPU’s
secondary and primary cache.

The main difference between a buffer and a cache is that a buffer may hold only the
existing copy of a data item, while a cache, by definition, holds a copy on faster storage
of an item that resides elsewhere.

4. Spooling and Device Reservation –


A spool is a buffer that holds the output of a device, such as a 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
mixes together.

The OS solves this problem by preventing all output from continuing to the printer. The
output of all applications is spooled in a separate disk file. When an application finishes
printing then the spooling system queues the corresponding spool file for output to the
printer.

5. Error Handling –
An OS that uses protected memory can guard against many kinds of hardware and
application errors so that a complete system failure is not the usual result of each minor
mechanical glitch, Devices, and I/O transfers can fail in many ways, either for transient
reasons, as when a network becomes overloaded or for permanent reasons, as when a disk
controller becomes defective.
Error Handling Strategies: Ensuring robust error handling is a critical aspect of the
Kernel I/O Subsystem to maintain the stability and reliability of the operating system.
The strategies employed for error handling involve mechanisms for detecting, reporting,

147
and recovering from I/O errors. Below are key components of error handling strategies
within the Kernel I/O Subsystem:
1. Error Detection Mechanisms: The Kernel I/O Subsystem incorporates various
mechanisms to detect I/O errors promptly
2. Error Reporting: Once an error is detected, the Kernel I/O Subsystem employs
mechanisms to report the error to higher levels of the operating system or user
applications.
3. Error Recovery Mechanisms: Recovering from I/O errors is crucial to maintaining
system stability.
4. User Notification: Informing users or administrators about I/O errors is essential
for timely intervention and system maintenance:

User Alerts: Providing alerts to users, either through the user interface or system
notifications, can prompt immediate attention to potential issues.
Automated Notifications: Implementing automated notification systems, such as emails
or messages, to inform system administrators about critical errors for proactive system
management.

6. I/O Protection –
Errors and the issue of protection are closely related. A user process may attempt to issue illegal
I/O instructions to disrupt the normal function of a system. We can use the various mechanisms
to ensure that such disruption cannot take place in the system.

The Kernel I/O Subsystem in Operating System


An Operating System (OS) is a complex software program that manages the hardware and
software resources of a computer system. One of the critical components of an OS is the Kernel
I/O Subsystem, which provides an interface between the operating system and input/output (I/O)
devices. The Kernel I/O Subsystem manages the I/O requests made by the user applications and
translates them into hardware commands that the devices can understand. In this article, we will
discuss the importance of the Kernel I/O Subsystem and its advantages and disadvantages.

Importance of Kernel I/O Subsystem

The Kernel I/O Subsystem is an essential part of any modern Operating System. It provides a
unified and consistent interface to the I/O devices, which enables the user applications to access
them without knowing the details of the underlying hardware. The Kernel I/O Subsystem also
manages the concurrency and synchronization issues that arise when multiple applications try to
access the same device simultaneously.
148
Advantages of Kernel I/O Subsystem

● Device Independence: The Kernel I/O Subsystem provides device independence to the user
applications. It abstracts the hardware details and provides a unified interface to the devices.
This means that the application developers can write code that is independent of the hardware
platform, and the Kernel I/O Subsystem takes care of the hardware-specific details.

● Efficient Resource Management: The Kernel I/O Subsystem provides efficient resource
management for the I/O devices. It manages the I/O requests and schedules them in a way
that optimizes the usage of the available resources. This ensures that the I/O devices are not
over utilized, and the system remains responsive.

● Concurrency Management: The Kernel I/O Subsystem manages the concurrency issues
that arise when multiple applications try to access the same device simultaneously. It ensures
that the applications get exclusive access to the device when needed and allows multiple
applications to share the device when appropriate.

Disadvantages of Kernel I/O Subsystem

● Complex Implementation: The Kernel I/O Subsystem is a complex software component


that requires a lot of resources to implement and maintain. Any issues with the Kernel I/O
Subsystem can affect the performance and stability of the entire system.

● Security Risks: The Kernel I/O Subsystem can pose security risks to the system if not
implemented correctly. Attackers can exploit vulnerabilities in the Kernel I/O Subsystem to
gain unauthorized access to the system or cause a denial-of-service attack.

Functions and services offered by the Kernel:


1. Process management: Save context of the interrupted program, dispatch a process,
manipulate scheduling lists.
2. Process communication: Send and receive interposes messages.
3. Memory management: Set memory protection information, swap-in/ swap-out, handle page
fault.
4. I/O management: Initiate I/O, process I/O completion interrupt, recover from I/O errors.
5. File management: Open a file, read/ write data.

149
6. Security and protection: Add authentication information for a new user, maintain
information for file protection.
7. Network management: Send/ receive data through a message.

LECTURE 47
I/O Buffering
I/O Buffering and its Various Techniques

A buffer is a memory area that stores data being transferred between two devices or between a
device and an application.

Uses of I/O Buffering:

● Buffering is done to deal effectively with a speed mismatch between the producer and
consumer of the data stream.

● A buffer is produced in main memory to heap up the bytes received from modem.

● After receiving the data in the buffer, the data gets transferred to the disk from the buffer in a
single operation.

● This process of data transfer is not instantaneous, therefore the modem needs another buffer
in order to store additional incoming data.

150
● When the first buffer gets filled, then it is requested to transfer the data to disk.

● The modem then starts filling the additional incoming data in the second buffer while the
data in the first buffer gets transferred to disk.

● When both the buffers complete their tasks, then the modem switches back to the first buffer
while the data from the second buffer gets transferred to the disk.

● The use of two buffers disintegrates the producer and the consumer of the data, thus
minimizing the time requirements between them.

● Buffering also provides variations for devices that have different data transfer sizes.

Types of various I/O buffering techniques:


1. Single buffer: A buffer is provided by the Operating system to the system portion of the main
memory.
Block oriented device –

● System buffer takes the input.

● After taking the input, the block gets transferred to the user space by the process and then
the process requests for another block.

● Two blocks works simultaneously, when one block of data is processed by the user
process, the next block is being read in.

● OS can swap the processes.

● OS can record the data of system buffer to user processes.

Stream oriented device –

● Line- at a time operation is used for scroll made terminals. User inputs one line at a time,
with a carriage return signaling at the end of a line.

● Byte-at a time operation is used on forms mode, terminals when each keystroke is
significant.

151
2. Double buffer:
Block oriented –

● There are two buffers in the system.

● One buffer is used by the driver or controller to store data while waiting for it to be taken
by a higher level of the hierarchy.

● Another buffer is used to store data from the lower level module.

● Double buffering is also known as buffer swapping.

● A major disadvantage of double buffering is that the complexity of the process increases.

● If the process performs rapid bursts of I/O, then using double buffering may be deficient.

Stream oriented –

● Line- at a time I/O, the user process need not be suspended for input or output, unless the
process runs ahead of the double buffer.

● Byte- at a time operations, a double buffer offers no advantage over a single buffer of
twice the length.

3. Circular buffer:

● When more than two buffers are used, the collection of buffers is itself referred to as a
circular buffer.

● In this, the data is not directly passed from the producer to the consumer because the data
would change due to overwriting of buffers before they had been consumed.
152
● The producer can only fill up to buffer i-1 while data in buffer is waiting to be consumed.

LECTURE 48

Disk Storage and Disk Scheduling

153
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.

Importance of Disk Scheduling in Operating System

● 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 this 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.

● Disk Scheduling Algorithms

● FCFS (First Come First Serve)

● SSTF (Shortest Seek Time First)

● SCAN (Elevator Algorithm)

● C-SCAN (Circular SCAN)

● LOOK

● C-LOOK

Key Terms Associated with Disk Scheduling

● Seek Time: Seek time is the time taken to locate the disk arm to a specified track where the
data is to be read or written. So the disk scheduling algorithm that gives a minimum average
seek time is better.

● Rotational Latency: Rotational Latency is the time taken by the desired sector of the disk to
rotate into a position so that it can access the read/write heads. So the disk scheduling
algorithm that gives minimum rotational latency is better.

● Transfer Time: Transfer time is the time to transfer the data. It depends on the rotating
speed of the disk and the number of bytes to be transferred.

154
● Disk Access Time:

Disk Access Time = Seek Time + Rotational Latency + Transfer Time


Total Seek Time = Total head Movement * Seek Time

Disk Access Time and Disk Response Time

● Disk Response Time: Response Time is the average time spent by a request waiting to
perform its I/O operation. The average Response time is the response time of all
requests. Variance Response Time is the measure of how individual requests are serviced
with respect to average response time. So the disk scheduling algorithm that gives minimum
variance response time is better.

Disk Scheduling Algorithms

There are several Disk Several Algorithms. We will discuss each one of them.

FCFS (First Come First Serve)

FCFS is the simplest of all Disk Scheduling Algorithms. In FCFS, the requests are addressed in
the order they arrive in the disk queue. Let us understand this with the help of an example.

155
First Come First Serve

Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is: 50
So, total overhead movement (total distance covered by the disk arm) =
(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16) =642

Advantages of FCFS
Here are some of the advantages of First Come First Serve.

● Every request gets a fair chance

● No indefinite postponement

Disadvantages of FCFS
Here are some of the disadvantages of First Come First Serve.

● Does not try to optimize seek time

● May not provide the best possible service

SSTF (Shortest Seek Time First)


In SSTF (Shortest Seek Time First), requests having the shortest seek time are executed first. So,
the seek time of every request is calculated in advance in the queue and then they are scheduled
according to their calculated seek time. As a result, the request near the disk arm will get
executed first. SSTF is certainly an improvement over FCFS as it decreases the average response
time and increases the throughput of the system. Let us understand this with the help of an
example.

156
Example:

Shortest Seek Time First

Suppose the order of request is- (82,170,43,140,24,16,190)


And current position of Read/Write head is: 50
So,
Total overhead movement (total distance covered by the disk arm) =
(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170) =208

Advantages of Shortest Seek Time First


Here are some of the advantages of Shortest Seek Time First.

● The average Response Time decreases

● Throughput increases

Disadvantages of Shortest Seek Time First


Here are some of the disadvantages of Shortest Seek Time First.

● Overhead to calculate seek time in advance

● Can cause Starvation for a request if it has a higher seek time as compared to incoming
requests

● The high variance of response time as SSTF favors only some requests

157
SCAN

In the SCAN algorithm the disk arm moves in a particular direction and services the requests
coming in its path and after reaching the end of the disk, it reverses its direction and again
services the request arriving in its path. So, this algorithm works as an elevator and is hence also
known as an elevator algorithm. As a result, the requests at the midrange are serviced more and
those arriving behind the disk arm will have to wait.
Example:

SCAN Algorithm

Suppose the requests to be addressed are- 82, 170, 43, 140, 24, 16, 190. And the Read/Write arm
is at 50, and it is also given that the disk arm should move “towards the larger value”.
Therefore, the total overhead movement (total distance covered by the disk arm) is calculated as
= (199-50) + (199-16) = 332

Advantages of SCAN Algorithm

Here are some of the advantages of the SCAN Algorithm.

● High throughput

● Low variance of response time

● Average response time

Disadvantages of SCAN Algorithm


Here are some of the disadvantages of the SCAN Algorithm.

158
● Long waiting time for requests for locations just visited by disk arm

LECTURE 49

C-SCAN

In the SCAN algorithm, the disk arm again scans the path that has been scanned, after reversing
its direction. So, it may be possible that too many requests are waiting at the other end or there
may be zero or few requests pending at the scanned area.
These situations are avoided in the CSCAN algorithm in which the disk arm instead of reversing
its direction goes to the other end of the disk and starts servicing the requests from there. So, the
disk arm moves in a circular fashion and this algorithm is also similar to the SCAN algorithm
hence it is known as C-SCAN (Circular SCAN).

159
Example:

Circular SCAN

Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at


50, and it is also given that the disk arm should move “towards the larger value”.
So, the total overhead movement (total distance covered by the disk arm) is calculated as:
=(199-50) + (199-0) + (43-0) = 391

Advantages of C-SCAN Algorithm


Here are some of the advantages of C-SCAN.

● Provides more uniform wait time compared to SCAN.

LOOK

LOOK Algorithm is similar to the SCAN disk scheduling algorithm except for the difference that
the disk arm in spite of going to the end of the disk goes only to the last request to be serviced in
front of the head and then reverses its direction from there only. Thus it prevents the extra delay
which occurred due to unnecessary traversal to the end of the disk.

160
Example:

LOOK Algorithm

Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at


50, and it is also given that the disk arm should move “towards the larger value”.
So, the total overhead movement (total distance covered by the disk arm) is calculated as:
= (190-50) + (190-16) = 314

C-LOOK

As LOOK is similar to the SCAN algorithm, in a similar way, C-LOOK is similar to the CSCAN
disk scheduling algorithm. In CLOOK, the disk arm in spite of going to the end goes only to the
last request to be serviced in front of the head and then from there goes to the other end’s last
request. Thus, it also prevents the extra delay which occurred due to unnecessary traversal to the
end of the disk.

Example:

1. Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm


is at 50, and it is also given that the disk arm should move “towards the larger value”

161
C-LOOK

So, the total overhead movement (total distance covered by the disk arm) is calculated as
= (190-50) + (190-16) + (43-16) = 341

162
LECTURE 50

RAID

RAID (Redundant Arrays of Independent Disks)

RAID is a technique that makes use of a combination of multiple disks instead of using a single
disk for increased performance, data redundancy, or both. The term was coined by David
Patterson, Garth A. Gibson, and Randy Katz at the University of California, Berkeley in 1987.

Why Data Redundancy?

Data redundancy, although taking up extra space, adds to disk reliability. This means, that in
case of disk failure, if the same data is also backed up onto another disk, we can retrieve the data
and go on with the operation. On the other hand, if the data is spread across multiple disks
without the RAID technique, the loss of a single disk can affect the entire data.

Key Evaluation Points for a RAID System

● Reliability: How many disk faults can the system tolerate?

● Availability: What fraction of the total session time is a system in uptime mode, i.e. how
available is the system for actual use?

● Performance: How good is the response time? How high is the throughput (rate of
processing work)? Note that performance contains a lot of parameters and not just the two.

● Capacity: Given a set of N disks each with B blocks, how much useful capacity is available
to the user?

RAID is very transparent to the underlying system. This means, that to the host system, it
appears as a single big disk presenting itself as a linear array of blocks. This allows older
technologies to be replaced by RAID without making too many changes to the existing code.

Different RAID Levels

1. RAID-0 (Stripping)

163
2. RAID-1 (Mirroring)
3. RAID-2 (Bit-Level Stripping with Dedicated Parity)
4. RAID-3 (Byte-Level Stripping with Dedicated Parity)
5. RAID-4 (Block-Level Stripping with Dedicated Parity)
6. RAID-5 (Block-Level Stripping with Distributed Parity)
7. RAID-6 (Block-Level Stripping with two Parity Bits)

Raid Controller

1. RAID-0 (Stripping)

● Blocks are “stripped” across disks.

RAID-0
164
● In the figure, blocks “0,1,2,3” form a stripe.

● Instead of placing just one block into a disk at a time, we can work with two (or more) blocks
placed into a disk before moving on to the next one.

Raid-0

Evaluation

● Reliability: 0
There is no duplication of data. Hence, a block once lost cannot be recovered.

● Capacity: N*B
The entire space is being used to store data. Since there is no duplication, N disks each
having B blocks are fully utilized.

Advantages

1. It is easy to implement.
2. It utilizes the storage capacity in a better way.

Disadvantages

1. A single drive loss can result in the complete failure of the system.
2. Not a good choice for a critical system.

2. RAID-1 (Mirroring)

165
● More than one copy of each block is stored in a separate disk. Thus, every block has two (or
more) copies, lying on different disks.

Raid-1

● The above figure shows a RAID-1 system with mirroring level 2.

● RAID 0 was unable to tolerate any disk failure. But RAID 1 is capable of reliability.

Evaluation

Assume a RAID system with mirroring level 2.

● Reliability: 1 to N/2
1 disk failure can be handled for certain because blocks of that disk would have duplicates on
some other disk. If we are lucky enough and disks 0 and 2 fail, then again this can be handled
as the blocks of these disks have duplicates on disks 1 and 3. So, in the best case, N/2 disk
failures can be handled.

● Capacity: N*B/2
only half the space is being used to store data. The other half is just a mirror of the already
stored data.
Advantages

1. It covers complete redundancy.


2. It can increase data security and speed.

Disadvantages

1. It is highly expensive.
2. Storage capacity is less.
166
3. RAID-2 (Bit-Level Stripping with Dedicated Parity)

● In Raid-2, the error of the data is checked at every bit level. Here, we use Hamming Code
Parity Method to find the error in the data.

● It uses one designated drive to store parity.

● The structure of Raid-2 is very complex as we use two disks in this technique. One word is
used to store bits of each word and another word is used to store error code correction.

● It is not commonly used.

Advantages

1. In case of Error Correction, it uses hamming code.


2. It uses one designated drive to store parity.
Disadvantages

1. It has a complex structure and high cost due to extra drive.


2. It requires an extra drive for error detection.

4. RAID-3 (Byte-Level Stripping with Dedicated Parity)

● It consists of byte-level striping with dedicated parity striping.

● At this level, we store parity information in a disc section and write to a dedicated parity
drive.

● Whenever failure of the drive occurs, it helps in accessing the parity drive, through which we
can reconstruct the data.

167
Raid-3

● Here Disk 3 contains the Parity bits for Disk 0, Disk 1, and Disk 2. If data loss occurs, we
can construct it with Disk 3.

Advantages

1. Data can be transferred in bulk.


2. Data can be accessed in parallel.
Disadvantages

1. It requires an additional drive for parity.


2. In the case of small-size files, it performs slowly.

5. RAID-4 (Block-Level Stripping with Dedicated Parity)

Instead of duplicating data, this adopts a parity-based approach.

Raid-4

168
● In the figure, we can observe one column (disk) dedicated to parity.

● Parity is calculated using a simple XOR function. If the data bits are 0,0,0,1 the parity bit is
XOR(0,0,0,1) = 1. If the data bits are 0,1,1,0 the parity bit is XOR(0,1,1,0) = 0. A simple
approach is that an even number of one’s results in parity 0, and an odd number of one’s
results in parity 1.

Raid-4

● Assume that in the above figure, C3 is lost due to some disk failure. Then, we can
recomputed the data bit stored in C3 by looking at the values of all the other columns and the
parity bit. This allows us to recover lost data.

Evaluation

● Reliability: 1
RAID-4 allows recovery of at most 1 disk failure (because of the way parity works). If more
than one disk fails, there is no way to recover the data.

● Capacity: (N-1)*B
One disk in the system is reserved for storing the parity. Hence, (N-1) disks are made
available for data storage, each disk having B blocks.

Advantages
1.It helps in reconstructing the data if at most one data is lost.

Disadvantages
2.It can’t help in reconstructing when more than one data is lost.

6. RAID-5 (Block-Level Stripping with Distributed Parity)

169
● This is a slight modification of the RAID-4 system where the only difference is that the
parity rotates among the drives.

Raid-5

● In the figure, we can notice how the parity bit “rotates”.

● This was introduced to make the random write performance better.

Evaluation

● Reliability: 1
RAID-5 allows recovery of at most 1 disk failure (because of the way parity works). If more
than one disk fails, there is no way to recover the data. This is identical to RAID-4.

● Capacity: (N-1)*B
Overall, space equivalent to one disk is utilized in storing the parity. Hence, (N-1) disks are
made available for data storage, each disk having B blocks.

Advantages

1. Data can be reconstructed using parity bits.


2. It makes the performance better.

Disadvantages

1. Its technology is complex and extra space is required.


2. If both discs get damaged, data will be lost forever.

170
7. RAID-6 (Block-Level Stripping with two Parity Bits)

● Raid-6 helps when there is more than one disk failure. A pair of independent parities are
generated and stored on multiple disks at this level. Ideally, you need four disk drives for this
level.

● There are also hybrid RAIDs, which make use of more than one RAID level nested one after
the other, to fulfill specific requirements.

Raid-6

Advantages

1. Very high data Accessibility.


2. Fast read data transactions.
Disadvantages
1. Due to double parity, it has slow write data transactions.
2. Extra space is required.

Advantages of RAID

● Data redundancy: By keeping numerous copies of the data on many disks, RAID can shield
data from disk failures.

● Performance enhancement: RAID can enhance performance by distributing data over


several drives, enabling the simultaneous execution of several read/write operations.

● Scalability: RAID is scalable, therefore by adding more disks to the array, the storage
capacity may be expanded.

171
● Versatility: RAID is applicable to a wide range of devices, such as workstations, servers,
and personal PCs

Disadvantages of RAID

● Cost: RAID implementation can be costly, particularly for arrays with large capacities.

● Complexity: The setup and management of RAID might be challenging.

● Decreased performance: The parity calculations necessary for some RAID configurations,
including RAID 5 and RAID 6, may result in a decrease in speed.

● Single point of failure: RAID is not a comprehensive backup solution, while offering data
redundancy. The array’s whole contents could be lost if the RAID controller malfunctions.

LECTURE 51

File System in Operating System

A file system is a collection of files and directories used by an operating system to organize the
storage of files and to provide a pathway for users to access those files. A file system is a
software layer that manages files and folders on an electronic storage device, such as a hard disk
or flash memory.
A computer file is defined as a medium used for saving and managing data in the computer
system. The data stored in the computer system is completely in digital format, although there
can be various types of files that help us to store the data.

172
What is a File System?

A file system is a method an operating system uses to store, organize, and manage files and
directories on a storage device. Some common types of file systems include:

1. FAT (File Allocation Table): An older file system used by older versions of Windows and
other operating systems.
2. NTFS (New Technology File System): A modern file system used by Windows. It supports
features such as file and folder permissions, compression, and encryption.
3. ext (Extended File System): A file system commonly used on Linux and Unix-based
operating systems.
4. HFS (Hierarchical File System): A file system used by macOS.
5. APFS (Apple File System): A new file system introduced by Apple for their Macs and iOS
devices.

A file is a collection of related information that is recorded on secondary storage. Or file is a


collection of logically related entities. From the user’s perspective, a file is the smallest allotment
of logical secondary storage.

The name of the file is divided into two parts as shown below
f)
● Name
● Extension, separated by a period.
Issues Handled By File System
A free space is created on the hard drive whenever a file is deleted from it. To reallocate them to
other files, many of these spaces may need to be recovered. Choosing where to store the files on
the hard disc is the main issue with files one block may or may not be used to store a file. It may
be kept in the disk’s non-contiguous blocks. We must keep track of all the blocks where the files
are partially located.

Operations on the File

A file is a collection of logically related data that is recorded on the secondary storage in the
form of sequence of operations. The content of the files are defined by its creator who is creating
the file. The various operations which can be implemented on a file such as read, write, open and
close etc. are called file operations. These operations are performed by the user by using the
commands provided by the operating system. Some common operations are as follows:
173
1. Create operation:
This operation is used to create a file in the file system. It is the most widely used operation
performed on the file system. To create a new file of a particular type the associated application
program calls the file system. This file system allocates space to the file. As the file system
knows the format of directory structure, so entry of this new file is made into the appropriate
directory.
2. Open operation:
This operation is the common operation performed on the file. Once the file is created, it must be
opened before performing the file processing operations. When the user wants to open a file, it
provides a file name to open the particular file in the file system. It tells the operating system to
invoke the open system call and passes the file name to the file system.
3. Write operation:
This operation is used to write the information into a file. A system call write is issued that
specifies the name of the file and the length of the data has to be written to the file. Whenever the
file length is increased by specified value and the file pointer is repositioned after the last byte
written.
4. Read operation:
This operation reads the contents from a file. A Read pointer is maintained by the OS, pointing
to the position up to which the data has been read.
5. Re-position or Seek operation:

The seek system call re-positions the file pointers from the current position to a specific place in
the file i.e. forward or backward depending upon the user's requirement. This operation is
generally performed with those file management systems that support direct access files.

6. Delete operation:

Deleting the file will not only delete all the data stored inside the file it is also used so that disk
space occupied by it is freed. In order to delete the specified file the directory is searched. When
the directory entry is located, all the associated file space and the directory entry is released.

7. Truncate operation:

Truncating is simply deleting the file except deleting attributes. The file is not completely
deleted although the information stored inside the file gets replaced.

8. Close operation:

174
When the processing of the file is complete, it should be closed so that all the changes made
permanent and all the resources occupied should be released. On closing it deallocates all the
internal descriptors that were created when the file was opened.

9. Append operation:
This operation adds data to the end of the file.

10. Rename operation:


This operation is used to rename the existing file.

FILE ORGANIZATION AND ACCESS MECHANISM

File Order of records Records can be deleted Access mode


organization or replaced?
Sequential Order in which they A record cannot be Sequential only
were written deleted, but its space can
be reused for a same-
length record.
Line-sequential Order in which they No Sequential only
were written
Indexed Collating sequence Yes Sequential, random,

175
by key field or dynamic
Relative Order of relative Yes Sequential, random,
record numbers or dynamic
File organization and access mode

File Access Methods

Various ways to access files stored in secondary memory


1. Sequential Access

Most of the operating systems access the file sequentially. In other words, we can say that most
of the files need to be accessed sequentially by the operating system.
In sequential access, the OS read the file word by word. A pointer is maintained which initially
points to the base address of the file. If the user wants to read first word of the file then the
pointer provides that word to the user and increases its value by 1 word. This process continues
till the end of the file.
Modern word systems do provide the concept of direct access and indexed access but the most
used method is sequential access due to the fact that most of the files such as text files, audio
files, video files, etc need to be sequentially accessed.
2. Direct Access

The Direct Access is mostly required in the case of database systems. In most of the cases, we
need filtered information from the database. The sequential access can be very slow and
inefficient in such cases.
176
Suppose every block of the storage stores 4 records and we know that the record we needed is
stored in 10th block. In that case, the sequential access will not be implemented because it will
traverse all the blocks in order to access the needed record.
Direct access will give the required result despite of the fact that the operating system has to
perform some complex tasks such as determining the desired block number. However, that is
generally implemented in database applications.

3. Indexed Access

If a file can be sorted on any of the filed then an index can be assigned to a group of certain
records. However, A particular record can be accessed by its index. The index is nothing but the
address of a record in the file.
In index accessing, searching in a large database became very quick and easy but we need to
have some extra space in the memory to store the index value.

File Directories
Directory Structure in OS (Operating System)
What is a directory?

Directory can be defined as the listing of the related files on the disk. The directory may store
some or the entire file attributes.
To get the benefit of different file systems on the different operating systems, A hard disk can be
divided into the number of partitions of different sizes. The partitions are also called volumes or
mini disks.

177
Each partition must have at least one directory in which, all the files of the partition can be listed.
A directory entry is maintained for each file in the directory which stores all the information
related to that file.

A directory can be viewed as a file which contains the Meta data of the bunch of files.

Every Directory supports a number of common operations on the file:

1. File Creation
2. Search for the file
3. File deletion
4. Renaming the file
5. Traversing Files
6. Listing of files

Single Level Directory

The simplest method is to have one big list of all the files on the disk. The entire system will
contain only one directory which is supposed to mention all the files present in the file system.
The directory contains one entry per each file present on the file system.

178
This type of directories can be used for a simple system.
Advantages
1. Implementation is very simple.
2. If the sizes of the files are very small then the searching becomes faster.
3. File creation, searching, deletion is very simple since we have only one directory.

Disadvantages
1. We cannot have two files with the same name.
2. The directory may be very big therefore searching for a file may take so much time.
3. Protection cannot be implemented for multiple users.
4. There are no ways to group same kind of files.
5. Choosing the unique name for every file is a bit complex and limits the number of files in
the system because most of the Operating System limits the number of characters used to
construct the file name.

Two Level Directory

In two level directory systems, we can create a separate directory for each user. There is one
master directory which contains separate directories dedicated to each user. For each user, there
is a different directory present at the second level, containing group of user's file. The system
doesn't let a user to enter in the other user's directory without permission.

179
Characteristics of two level directory system

1. Each files has a path name as /User-name/directory-name/


2. Different users can have the same file name.
3. Searching becomes more efficient as only one user's list needs to be traversed.
4. The same kind of files cannot be grouped into a single directory for a particular user.

Every Operating System maintains a variable as PWD which contains the present directory name
(present user name) so that the searching can be done appropriately.
Advantages:
● The main advantage is there can be more than two files with same name, and would be very
helpful if there are multiple users.
● A security would be there which would prevent user to access other user’s files.
● Searching of the files becomes very easy in this directory structure.

Disadvantages:
● As there is advantage of security, there is also disadvantage that the user cannot share the file
with the other users.

● Unlike the advantage users can create their own files, users don’t have the ability to create
subdirectories.
180
● Scalability is not possible because one use can’t group the same types of files together.

Tree Structured Directory

In Tree structured directory system, any directory entry can either be a file or sub directory. Tree
structured directory system overcomes the drawbacks of two level directory system. The similar
kind of files can now be grouped in one directory.
Each user has its own directory and it cannot enter in the other user's directory. However, the
user has the permission to read the root's data but he cannot write or modify this. Only
administrator of the system has the complete access of root directory.
Searching is more efficient in this directory structure. The concept of current working directory
is used. A file can be accessed by two types of path, either relative or absolute.
Absolute path is the path of the file with respect to the root directory of the system while relative
path is the path with respect to the current working directory of the system. In tree structured
directory systems, the user is given the privilege to create the files as well as directories.

Advantages:
● This directory structure allows subdirectories inside a directory.

● The searching is easier.

● File sorting of important and unimportant becomes easier.

● This directory is more scalable than the other two directory structures explained .
181
Disadvantages:
● As the user isn’t allowed to access other user’s directory, this prevents the file sharing among
users.

● As the user has the capability to make subdirectories, if the number of subdirectories increase
the searching may become complicated.

● Users cannot modify the root directory data.

● If files do not fit in one, they might have to be fit into other directories.

Acyclic-Graph Structured Directories

The tree structured directory system doesn't allow the same file to exist in multiple directories
therefore sharing is major concern in tree structured directory system. We can provide sharing by
making the directory an acyclic graph. In this system, two or more directory entry can point to
the same file or sub directory. That file or sub directory is shared between the two directory
entries.
These kinds of directory graphs can be made using links or aliases. We can have multiple paths
for a same file. Links can either be symbolic (logical) or hard link (physical).
If a file gets deleted in acyclic graph structured directory system, then
1. In the case of soft link, the file just gets deleted and we are left with a dangling pointer.
2. In the case of hard link, the actual file will be deleted only if all the references to it gets
deleted.

182
Advantages:

● Sharing of files and directories is allowed between multiple users.

● Searching becomes too easy.

● Flexibility is increased as file sharing and editing access is there for multiple users.

Disadvantages:

● Because of the complex structure it has, it is difficult to implement this directory structure.

● The user must be very cautious to edit or even deletion of file as the file is accessed by
multiple users.

● If we need to delete the file, then we need to delete all the references of the file in order to
delete it permanently.

183
LECTURE 52

File Sharing in OS

File sharing in an Operating System (OS) denotes how information and files are shared between
different users, computers, or devices on a network; and files are units of data that are stored in a
computer in the form of documents/images/videos or any others types of information needed.

For Example: Suppose letting your computer talk to another computer and exchange pictures,
documents, or any useful data. This is generally useful when one wants to work on a project with
others, send files to friends, or simply shift stuff to another device. Our OS provides ways to do
this like email attachments, cloud services, etc. to make the sharing process easier and more
secure. Now, file sharing is nothing like a magical bridge between Computer A to Computer B
allowing them to swap some files with each other.

Primary Terminology Related to File Sharing

● Folder/Directory: It is basically like a container for all of our files on a computer. The
folder can contain files and even other folders maintaining like hierarchical structure for
organizing data.
184
● Networking: It is involved in connecting computers or devices where we need to share the
resources. Networks can be local (LAN) or global (Internet).

● IP Address: It is numerical data given to every connected device on the network

● Protocol: It is given as the set of rules which drives the communication between devices on a
network. In the context of file sharing, protocols define how files are transferred between
computers. File Transfer Protocol (FTP): FTP is a standard network protocol used to
transfer files between a client and a server on a computer network.

Various Ways to Achieve File Sharing


.
1. Server Message Block (SMB)

SMB is like a network based file sharing protocol mainly used in windows operating systems. It
allows our computer to share files/printer on a network. SMB is now the standard way for
seamless file transfer method and printer sharing.
Example: Imagine in a company where the employees have to share the files on a particular
project. Here SMB is employed to share files among all the windows based operating system.
orate on projects. SMB/CIFS is employed to share files between Windows-based computers.
Users can access shared folders on a server, create, modify, and delete files.

SMB File Sharing

2. Network File System (NFS)

NFS is a distributed based file sharing protocol mainly used in Linux/Unix based operating
System. It allows a computer to share files over a network as if they were based on local. It
provides a efficient way of transfer of files between servers and clients.

185
Example: Many Programmer/Universities/Research Institution uses Unix/Linux based
Operating System. The Institutes puts up a global server datasets using NFS. The Researchers
and students can access these shared directories and everyone can collaborate on it.

NFS File Sharing

3. File Transfer Protocol (FTP)

It is the most common standard protocol for transferring of the files between a client and a server
on a computer network. FTPs supports both uploading and downloading of the files, here we can
download, upload and transfer of files from Computer A to Computer B over the internet or
between computer systems.
Example: Suppose the developer makes changes on the server. Using the FTP protocol, the
developer connects to the server they can update the server with new website content and
updates the existing file over there.

186
FTP File Sharing

4. Cloud-Based File Sharing

It involves the famous ways of using online services like Google Drive, Drop Box , One
Drive ,etc. Any user can store files over these cloud services and they can share that with others,
and providing access from many users. It includes collaboration in real time file sharing and
version control access.

Ex: Several students working on a project and they can use Google Drive to store and share for
that purpose. They can access the files from any computer or mobile devices and they can make
changes in real time and track the changes over there.

Cloud Based File Sharing

These all file sharing methods serves different purpose and needs according to the requirements
and flexibility of the users based on the operating system.

File System Implementation in Operating System

A file is a collection of related information. The file system resides on secondary storage and
provides efficient and convenient access to the disk by allowing data to be stored, located, and
retrieved.
File system implementation in an operating system refers to how the file system manages the
storage and retrieval of data on a physical storage device such as a hard drive, solid-state drive,
or flash drive. The file system implementation includes several components, including:
1. File System Structure: The file system structure refers to how the files and directories are
organized and stored on the physical storage device. This includes the layout of file systems
data structures such as the directory structure, file allocation table, and in odes.

187
2. File Allocation: The file allocation mechanism determines how files are allocated on the
storage device. This can include allocation techniques such as contiguous allocation, linked
allocation, indexed allocation, or a combination of these techniques.
3. Data Retrieval: The file system implementation determines how the data is read from and
written to the physical storage device. This includes strategies such as buffering and caching
to optimize file I/O performance.
4. Security and Permissions: The file system implementation includes features for managing
file security and permissions. This includes access control lists (ACLs), file permissions, and
ownership management.
5. Recovery and Fault Tolerance: The file system implementation includes features for
recovering from system failures and maintaining data integrity. This includes techniques such
as journaling and file system snapshots.
File system implementation is a critical aspect of an operating system as it directly impacts the
performance, reliability, and security of the system. Different operating systems use different file
system implementations based on the specific needs of the system and the intended use cases.
Some common file systems used in operating systems include NTFS and FAT in Windows, and
ext4 and XFS in Linux.
The file system is organized into many layers:

1. I/O Control level – Device drivers act as an interface between devices and OS, they help to
transfer data between disk and main memory. It takes block number as input and as output, it
gives low-level hardware-specific instruction.

188
2. Basic file system – It Issues general commands to the device driver to read and write
physical blocks on disk. It manages the memory buffers and caches. A block in the buffer can
hold the contents of the disk block and the cache stores frequently used file system metadata.
3. File organization Module – It has information about files, the location of files and their
logical and physical blocks. Physical blocks do not match with logical numbers of logical
blocks numbered from 0 to N. It also has a free space that tracks unallocated blocks.
4. Logical file system – It manages metadata information about a file i.e includes all details
about a file except the actual contents of the file. It also maintains via file control blocks. File
control block (FCB) has information about a file – owner, size, permissions, and location of
file contents.

Advantages:
1. Duplication of code is minimized.
2. Each file system can have its own logical file system.
3. File system implementation in an operating system provides several advantages, including:
4. Efficient Data Storage: File system implementation ensures efficient data storage on a
physical storage device. It provides a structured way of organizing files and directories,
which makes it easy to find and access files.
5. Data Security: File system implementation includes features for managing file security and
permissions. This ensures that sensitive data is protected from unauthorized access.
6. Data Recovery: The file system implementation includes features for recovering from
system failures and maintaining data integrity. This helps to prevent data loss and ensures
that data can be recovered in the event of a system failure.
7. Improved Performance: File system implementation includes techniques such as buffering
and caching to optimize file I/O performance. This results in faster access to data and
improved overall system performance.
8. Scalability: File system implementation can be designed to be scalable, making it possible to
store and retrieve large amounts of data efficiently.
9. Flexibility: Different file system implementations can be designed to meet specific needs
and use cases. This allows developers to choose the best file system implementation for their
specific requirements.
10. Cross-Platform Compatibility: Many file system implementations are cross-platform
compatible, which means they can be used on different operating systems. This makes it easy
to transfer files between different systems.
In summary, file system implementation in an operating system provides several advantages,
including efficient data storage, data security, data recovery, improved performance, scalability,

189
flexibility, and cross-platform compatibility. These advantages make file system implementation
a critical aspect of any operating system.

Disadvantages

If we access many files at the same time then it results in low performance. We can implement a
file system by using two types of data structures:
1. Boot Control Block – It is usually the first block of volume and it contains information
needed to boot an operating system. In UNIX it is called the boot block and in NTFS it is
called the partition boot sector.
2. Volume Control Block – It has information about a particular partition ex:- free block count,
block size and block pointers, etc. In UNIX it is called superblock and in NTFS it is stored in
the master file table.
3. Directory Structure – They store file names and associated inode numbers. In UNIX,
includes file names and associated file names and in NTFS, it is stored in the master file
table.
4. Per-File FCB – It contains details about files and it has a unique identifier number to allow
association with the directory entry. In NTFS it is stored in the master file table.
5. Mount Table – It contains information about each mounted volume.
6. Directory-Structure cache – This cache holds the directory information of recently
accessed directories.
7. System-wide open-file table – It contains the copy of the FCB of each open file.
8. Per-process open-file table – It contains information opened by that particular process and it
maps with the appropriate system-wide open-file.
9. Linear List – It maintains a linear list of filenames with pointers to the data blocks. It is
time-consuming also. To create a new file, we must first search the directory to be sure that
no existing file has the same name then we add a file at the end of the directory. To delete a
file, we search the directory for the named file and release the space. To reuse the directory
entry either we can mark the entry as unused or we can attach it to a list of free directories.
10. Hash Table – The hash table takes a value computed from the file name and returns a
pointer to the file. It decreases the directory search time. The insertion and deletion process
of files is easy. The major difficulty is hash tables are its generally fixed size and hash tables
are dependent on the hash function of that size.

Implementation Issues

Management of disc space: To prevent space wastage and to guarantee that files can always be
stored in contiguous blocks, file systems must manage disc space effectively. Free space
190
management, fragmentation prevention, and garbage collection are methods for managing disc
space.
Checking for consistency and repairing errors: The consistency and error-free operation of
files and directories must be guaranteed by file systems. Journaling, check summing, and
redundancy are methods for consistency checking and error recovery. File systems may need to
perform recovery operations if errors happen in order to restore lost or damaged data.
Locking files and managing concurrency: To prevent conflicts and guarantee data integrity,
file systems must control how many processes or users can access a file at once. File locking,
semaphore, and other concurrency-controlling methods are available.
Performance optimization: File systems need to optimize performance by reducing file access
times, increasing throughput, and minimizing system overhead. Caching, buffering, prefetching,
and parallel processing are methods for improving performance.

Key Steps Involved In File System Implementation

File system implementation is a crucial component of an operating system, as it provides an


interface between the user and the physical storage device. Here are the key steps involved in file
system implementation:
1. Partitioning the storage device: The first step in file system implementation is to partition
the physical storage device into one or more logical partitions. Each partition is formatted
with a specific file system that defines the way files and directories are organized and stored.
2. File system structures: File system structures are the data structures used by the operating
system to manage files and directories. Some of the key file system structures include the
superblock, inode table, directory structure, and file allocation table.
3. Allocation of storage space: The file system must allocate storage space for each file and
directory on the storage device. There are several methods for allocating storage space,
including contiguous, linked, and indexed allocation.
4. File operations: The file system provides a set of operations that can be performed on files
and directories, including create, delete, read, write, open, close, and seek. These operations
are implemented using the file system structures and the storage allocation methods.
5. File system security: The file system must provide security mechanisms to protect files and
directories from unauthorized access or modification. This can be done by setting file
permissions, access control lists, or encryption.
6. File system maintenance: The file system must be maintained to ensure efficient and
reliable operation. This includes tasks such as disk defragmentation, disk checking, and
backup and recovery.

191
File system protection and security
Introduction

File protection in an operating system is the process of securing files from unauthorized access,
alteration, or deletion. It is critical for data security and ensures that sensitive information
remains confidential and secure. Operating systems provide various mechanisms and techniques
such as file permissions, encryption, access control lists, auditing, and physical file security to
protect files. Proper file protection involves user authentication, authorization, access control,
encryption, and auditing. Ongoing updates and patches are also necessary to prevent security
breaches. File protection in an operating system is essential to maintain data security and
minimize the risk of data breaches and other security incidents.

What is File protection?

File protection in an operating system refers to the various mechanisms and techniques used to
secure files from unauthorized access, alteration, or deletion. It involves controlling access to
files, ensuring their security and confidentiality, and preventing data breaches and other security
incidents. Operating systems provide several file protection features, including file permissions,
encryption, access control lists, auditing, and physical file security. These measures allow
administrators to manage access to files, determine who can access them, what actions can be
performed on them, and how they are stored and backed up. Proper file protection requires
ongoing updates and patches to fix vulnerabilities and prevent security breaches. It is crucial for
data security in the digital age where cyber threats are prevalent. By implementing file protection
measures, organizations can safeguard their files, maintain data confidentiality, and minimize the
risk of data breaches and other security incidents.

Type of File protection

File protection is an essential component of modern operating systems, ensuring that files are
secured from unauthorized access, alteration, or deletion. In this context, there are several types
of file protection mechanisms used in operating systems to provide robust data security.

● File Permissions

192
● Encryption

● Access Control Lists (ACLs)

● Auditing and Logging

● Physical File Security

Overall, these types of file protection mechanisms are essential for ensuring data security and
minimizing the risk of data breaches and other security incidents in an operating system. The choice
of file protection mechanisms will depend on the specific requirements of the organization, as well as
the sensitivity and volume of the data being protected. However, a combination of these file
protection mechanisms can provide comprehensive protection against various types of threats and
vulnerabilities.

Advantages of File protection

File protection is an important aspect of modern operating systems that ensures data security and integrity by prevent

● Data Security

193
● Compliance

● Business Continuity

● Increased Productivity

● Enhanced Collaboration

● Reputation organization's reputation by


demonstrating a commitment to data security and compliance. By implementing robust file
protection mechanisms, organizations can build trust with their customers, partners, and
stakeholders, which can have a positive impact on their reputation and bottom line.

Disadvantages of File protection

There are also some potential disadvantages of file protection in an operating system, including

● Overhead

● Complexity

194
● Compatibility Issues

● Cost

● User Frustration

Type of File protection in File System

In computer systems, a lot of user’s information is stored, the objective of the operating system is
to keep safe the data of the user from the improper access to the system. Protection can be
provided in number of ways. For a single laptop system, we might provide protection by locking
the computer in a desk drawer or file cabinet. For multi-user systems, different mechanisms are
used for the protection.
Types of Access:
The files, which have direct access of the any user, have the need of protection. The files, which
are not accessible to other users, does not require any kind of protection. The mechanism of the
protection provide the facility of the controlled access by just limiting the types of access to the
file. Access can be given or not given to any user depends on several factors, one of which is the
type of access required. Several different types of operations can be controlled:

● Read – Reading from a file.

● Write – Writing or rewriting the file.

● Execute – Loading the file and after loading the execution process starts.

● Append – Writing the new information to the already existing file, editing must be end at the
end of the existing file.

● Delete – Deleting the file which is of no use and using its space for the another data.

● List – List the name and attributes of the file.

Operations like renaming, editing the existing file, copying; these can also be controlled. There
are many protection mechanisms. Each of them mechanism have different advantages and
disadvantages and must be appropriate for the intended application.

195
Access Control:
There are different methods used by different users to access any file. The general way of
protection is to associate identity-dependent access with all the files and directories, an list
called access-control list (ACL) which specify the names of the users and the types of access
associate with each of the user. The main problem with the access list is their length. If we want
to allow everyone to read a file, we must list all the users with the read access. This technique
has two undesirable consequences:
Constructing such a list may be a tedious and unrewarding task, especially if we do not know in
advance the list of the users in the system.
Previously, the entry of any directory is of the fixed size but now it changes to the variable size
which results in complicated space management. These problems can be resolved by use of a
condensed version of the access list. To condense the length of the access-control list, many
systems recognize three classification of users in connection with each file:

● Owner – Owner is the user who has created the file.

● Group – A group is a set of members who has similar needs and they are sharing the same
file.

● Universe – In the system, all other users are under the category called universe.

The most common recent approach is to combine access-control lists with the normal general
owner, group, and universe access control scheme. For example: Solaris uses the three categories
of access by default but allows access-control lists to be added to specific files and directories
when more fine-grained access control is desired.

Other Protection Approaches:


The access to any system is also controlled by the password. If the use of password is random
and it is changed often, this may result in limiting the effective access to a file.
The use of passwords has a few disadvantages:

● The number of passwords is very large so it is difficult to remember the large passwords.

● If one password is used for all the files, then once it is discovered, all files are accessible;
protection is on all-or-none basis

196
Key differences between the Security and Protection in Operating System

There are various head-to-head comparisons between the security and protection in the operating
system. Some comparisons of security and protection are as follows:

Features Security Protection

Definition It is a technique used in operating It is a technique used in operating


systems to address threats from outside systems to control hazards and maintain
the system to maintain its proper the system's proper functioning.
functioning.

Focus It mainly focuses on external threats to It mainly focuses on the internal threats
the system. of the system.

Policy It specifies whether or not a specific It outlines which users are permitted to
user is allowed to access the system. access a certain resource.

Functionality It offers a technique for protecting It offers a technique for controlling


system and user resources from access to processes, programs, and user
unauthorized access. resources.

Mechanism Security techniques include adding, It includes techniques like modifying a


deleting users, determining whether or resource's protection information and
not a certain user is authorized, determining whether a user may access
employing anti-malware software, etc. it.

Queries It is a wide phrase that handles more It comes with security and covers less
complicated queries. complex queries.

197
Important Questions (AKTU) of UNIT 5

1. Explain the term RAID and its characteristics. Also, explain various RAID levels with
their advantages and disadvantages.(AKTU 2023)
2. Explain the concept of file system management. Also, explain various file allocation and
file access mechanisms in details. (AKTU 2023)
3. Suppose the following disk request sequence (track numbers) for a disk with 100 tracks
is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial position of the R/W
head is on track 49. Calculate the net head movement using: (AKTU 2023)
(i) SSTF
(ii) SCAN
(iii) CSCAN
(iv) LOOK
4. Explain the followings: (AKTU 2023)
(i) Buffering
(ii) Polling
(iii) Direct Memory Access (DMA)
5. Explain tree level directory structure.(AKTU 2023)
6. Explain various operations associated with a file. (AKTU 2023)
7. Difference between Directory and File. (AKTU 2016-17)
8. Explain File organization and Access mechanism. (AKTU 2016-17)
9. What do you mean by caching, spooling and error handling, explain in detail. Explain
FCFS, SCAN & CSCAN scheduling with eg. (AKTU 2016-17)
10. Discuss the Linked, Contiguous and Index and multilevel Indexing file allocation
schemes. Which allocation scheme will minimize the amount of space required in
directory structure and why? (AKTU2017-18)
11. Write short notes on : (AKTU 2017-18)
i) I/O Buffering

198
ii) Disk storage and scheduling
12. Define seek time and latency time. (AKTU 2018-19)
13. Define SCAN and C-SCAN scheduling algorithms. (AKTU 2018-19)
14. A hard disk having 2000 cylinders, numbered from 0 to 1999. The drive is currently
serving the request at cylinder 143, and the previous request was at cylinder 125. The
status of the queue is as follows 86,1470,913,1774,948,1509,1022,1750,130. What is the
total distance (in cylinders) that the disk arm moves to satisfy the entire pending request
for each of the following disk-scheduling algorithms? (AKTU 2018-19)
(i) SSTF
(ii) FCFS
15. What are files and explain the access methods for files. (AKTU 2018-19)
16. Write are files and explain the access methods for files. (AKTU 2018-19)
(i) File system protection and security and
(ii) Linked File allocation methods
17. Explain the following methods. (AKTU 2015-16)
1. (i) Bit vector (iii) Linked List
2. (ii) Grouping (iv) Counting
18. What is directory? Explain any two ways to implement the directory. (AKTU 2015-16)
19. Suppose the moving head disk with 200 tracks is currently serving a request for track 143
and has just finished a request for track 125. If the queue of request is kept in FIFO order
86.147.91, 177.94.150.What is total head movement for the following scheduling :
(AKTU 2015-16)
3. (i) FCFS (ii) SSTF (iii) C-SCAN
20. Write short notes on: (AKTU 2015-16)
(i) I/O Buffering
(ii) Sequential File
(iii) Indexed File

199

You might also like