0% found this document useful (0 votes)
15 views48 pages

Ospart 3

The document provides an overview of I/O management in operating systems, detailing the types of I/O devices, their characteristics, and communication methods. It covers various I/O subsystem services such as scheduling, buffering, caching, spooling, error handling, and protection, as well as file concepts and organization. Additionally, it discusses directory structures and file allocation methods, including contiguous, linked list, and indexed allocation.

Uploaded by

jollyprachi01
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)
15 views48 pages

Ospart 3

The document provides an overview of I/O management in operating systems, detailing the types of I/O devices, their characteristics, and communication methods. It covers various I/O subsystem services such as scheduling, buffering, caching, spooling, error handling, and protection, as well as file concepts and organization. Additionally, it discusses directory structures and file allocation methods, including contiguous, linked list, and indexed allocation.

Uploaded by

jollyprachi01
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/ 48

I/O-Management

I/O Devices
• The I/O management module in the operating system provides a
means by which a process can interact with the outside world.
• Traditionally, the I/O system is regarded as one of the most
challenging to implement due to the diverse range of peripherals
that can be used, each with different configurations.
• External devices used in computer I/O can be broadly grouped
into three classes:
Human-readable devices: These include devices like monitors
and printers, which interact directly with humans.
Machine-readable devices: These devices, such as disks and
sensors, provide data that is processed by the computer.
Communication devices: This class includes networking
equipment and modems, facilitating communication between
different systems.
I/O Devices
Characteristics of I/O Devices
Devices vary across several dimensions:
Character-stream or block: Determines how data is transferred
between the device and the computer.
Sequential or random access: Defines how data can be accessed from
the device.
Synchronous or asynchronous: Specifies timing and coordination
between the device and the computer.
Sharable or dedicated: Indicates whether multiple processes can use
the device simultaneously.
Speed of operation: Refers to the rate at which data can be
transferred to or from the device.
Read-write, read-only, or write-only: Specifies the permissions and
capabilities for interacting with data on the device.
I/O Hardware
• I/O devices can be broadly categorized as storage,
communication, user-interface, and others.
• Devices communicate with the computer through signals sent
via wires or wirelessly.
• Devices connect to the computer using ports (e.g., serial or
parallel ports).
• A common set of wires connecting multiple devices is termed a bus.
I/O Hardware-
A Typical PC Bus Structure
I/O Hardware
Different types of Bus
1. PCI Bus (Peripheral Component Interconnect)
• The PCI bus connects high-speed components such as the
processor, memory, graphics controller, and the SCSI controller.
2. Expansion Bus
• Expansion Bus connects to the PCI Bus, to link Links slower devices
such as keyboard, parallel port, and serial port.
3. SCSI Bus (Small Computer System Interface)
• Connects multiple storage devices (disks) to the SCSI controller.
I/O Hardware
Registers for Device Communication
1. Data-in Register: Used by the CPU to read data from an input
device.
2. Data-out Register: Used by the CPU to send data to an output
device.
3. Status Register:Read by the CPU to check if a device is ready,
busy, or has encountered an error.
4. Control Register: Written by the CPU to control or configure
device settings (e.g., mode, command, etc.).
Direct I/O with Polling
• Polling is a technique used by the CPU to communicate with
input/output devices.
• The host checks the busy bit to see if the device is free.
• It writes data to the data-out register and sets the write bit.
• It sets the command ready bit to notify the device.
• The device sets the busy bit, reads the command and data, and
starts processing.
• If there's an issue, it sets the error bit.
• After completing, it clears the busy and command-ready bits.
Interrupt Driven I/O
• Device driver asks the I/O controller to start I/O.
• I/O controller begins the I/O operation.
• When the device is ready (input/output/error), it sends an
interrupt to the CPU.
• CPU detects the interrupt and pauses its current task.
• Interrupt handler runs and processes the data.
• CPU resumes the paused task after the handler finishes.
Interrupt Driven I/O
Direct Memory Access
• DMA is used to transfer large amounts of data (e.g., from a
disk) without involving the CPU for each byte.
• A special processor called the DMA controller handles the data
transfer.
• The CPU gives the DMA controller the source, destination, and
size of the data.
• The DMA controller transfers the data directly between device
and memory.
• After completion, it interrupts the CPU to notify that the
transfer is done.
• This allows the CPU to do other work while the transfer
happens in the background.
Direct Memory Access
1. Initialization:
• The CPU instructs the device driver to transfer disk data to
buffer at memory address X
• The driver informs the DMA controller with:
• Memory address X for the buffer,
• Number of bytes C to transfer,
• I/O device details.
2. Command Dispatch:
• The DMA controller instructs the disk controller (via IDE
controller) to send data.
Direct Memory Access
3. Data Transfer Begins:
• The disk controller starts sending data to the DMA controller,
one byte at a time, which then forwards it to memory location
X.
• For each byte transferred:
• Address is incremented,
• Counter C is decremented.
4. Completion:
• When C = 0, the DMA controller signals the CPU with an
interrupt indicating transfer completion
Direct Memory Access
I/O Subsystem Services
• The kernel provides several critical services for managing I/O
operations efficiently
1.I/O Scheduling
Definition: I/O scheduling determines the order in which I/O requests
are processed by storage devices to optimize efficiency.
Reasons for Scheduling: Minimize seek times and maximize
throughput to enhance overall system performance.
2. Buffering
Definition: Buffering is the process of temporarily storing data in a
buffer (a memory area) to manage differences in the speed or timing
of data flow between devices or processes.
Reasons for Buffering:
– Speed differences between fast and slow devices (e.g., CPU vs.
printer),
– Support for copy semantics makes sure source data isn’t changed
before the transfer completes.
I/O Subsystem Services
3. Caching
Definition: Caching is the process of storing frequently accessed
data in cache memory to reduce access time and improve system
performance.
Reasons for Caching:
– Faster Access: Cache memory provides quicker data retrieval
compared to main storage.
– Performance Boost: Enhances system speed by minimizing
access delays.
– Temporary Storage: Keeps data for a short time so it can be
used again or updated later.
I/O Subsystem Services
4. Spooling (Simultaneous Peripheral Operation On-Line)
Definition: Spooling is the process of placing data in a queue so that, it
can be accessed and used by devices like printers in the correct order
to improve system efficiency.
Reasons for Spooling:
– Queue Management: Manages data flow to avoid device overload.
– Temporary Storage: Holds data in a queue until the device is
ready.
– Examples: Commonly used for printing documents, where print
jobs are queued and processed in the order received, allowing
users to continue working without delays.
I/O Subsystem Services
5. Error Handling
Definition: Finds and fixes problems during I/O operations to
keep the system working properly.
Reasons for Error Handling:
– Detection:Identifies errors like device failures or data
corruption.
– Notification: Alerts users or administrators about I/O errors.
– Resolution: Tries to solve errors automatically or with help.
– Recovery: Restores I/O functionality to minimize downtime
and data loss.
– Importance: Keeps the system safe and working well.
I/O Subsystem Services
6. I/O Protection
Definition: I/O protection makes sure only allowed users or programs
can use input and output devices safely.
Key Aspects:
– Access Control: Decides who can use which devices.
– Data Integrity: Prevents unauthorized or unintended modifications
of the data being input or output.
– Resource Allocation: Manages sharable device access to prevent
conflicts and prioritize tasks.
– Error Handling: Handles problems safely when devices don’t work
right.
– Importance: Enhances system security and reliability by enforcing
access policies and mitigating risks associated with I/O operations.
Buffering
Definition: Buffering is the process of temporarily storing data in a
buffer (a memory area) to manage differences in the speed or
timing of data flow between devices or processes.
Reasons for Buffering:
– Speed differences between fast and slow devices (e.g., CPU vs.
printer),
– Support for copy semantics makes sure source data isn’t
changed before the transfer completes.
• Types of buffering:
• Single Buffering
• Double Buffering
• Circular Buffering
Single Buffering
• This is the easiest type of buffering. The system gives only one
small memory space (called a buffer) to use.
• The input device (called the producer) sends one piece (one block)
of data to the buffer.
• The user or program (called the receiver) takes that data from the
buffer.
• After that, the buffer is filled again with the next piece of data.
Double Buffering
• This is better than Single Buffering because it uses two memory
spaces (buffers) instead of one.
• First, the data goes into the first buffer, then it moves to the
second buffer.
• The receiver takes the data from the second buffer.
• While one buffer is busy getting new data, the other buffer sends
the previous data.
Circular Buffering
• An enhanced form of double buffering using more than two buffers.
• One buffer is used to insert new data, while the next buffer is processed
simultaneously.
• This process continues through all buffers , creating a continuous chain
of data handling.
• The consumer retrieves data from the last buffer after processing.
• Ideal for faster data transfers and managing large or bulky data
efficiently.
File Concept
• A computer file is defined as a medium used for saving and
managing data in the computer system.
• File systems are a crucial part of any OS, providing a structured
way to store, organize, and manage data on storage devices such
as hard drives, SSDs, and USB drives.
• A file is a collection of related information stored on secondary
storage (like a hard disk).
• A file name typically has two parts:
Name
Extension, separated by a period
File Concept
Attributes of the File
1.Name
Every file carries a name by which the file is recognized in the file
system.
One directory cannot have two files with the same name.
2.Identifier
Along with the name, Each File has its own extension which
identifies the type of the file.
For example, a text file has the extension .txt, A video file can have
the extension .mp4.
3.Type
Files are classified in different types such as video files, audio files,
text files, executable files, etc.
File Concept
4.Location
There are several locations on which, the files can be stored.
Each file carries its location as its attribute.
5.Size
The Size of the File is one of its most important attribute.
By size of the file, we mean the number of bytes acquired by the file in
the memory.
6.Protection
Files have permissions that control who can read, write, or execute
them.
Therefore each file carries its own set of permissions to the different
group of Users.
7.Time and Date
Every file carries a time stamp which contains the time and date on
which the file is last modified.
File Concept
8. Re-position or Seek operation:
The seek system call moves the file pointer from its current
position to a specific location within the file (either forward or
backward).
This operation is generally performed with those file management
systems that support direct access files.
9. Delete operation:
Deleting a file removes its stored data and frees up the disk space it
occupied.
The file system searches the directory for the file's entry, releasing
both the file's storage space and its directory entry upon deletion.
File Concept
7. Truncate operation:
Truncates all data in the file, leaving it empty.
Retains file metadata and attributes while clearing its contents.
8. Close operation:
Closing a file ensures that all changes made during processing are
permanently saved to storage.
Deallocates internal descriptors created when the file was opened,
freeing up system resources.
File Concept
• File organization and access mechanisms are related concepts in
the context of computer systems and storage, but they refer to
different aspects:
• File organization refers to how data is logically structured and
stored within a file.
• Access mechanism refers to how data within files is accessed by
programs or users.
• Following are the three methods :
Sequential file organization
Direct file organization
Indexed file organization
File Organization and Access Mechanism
1. Sequential file organization
Definition: Records are stored in a linear sequence; in the order they were
entered.
Access Method: Records are accessed sequentially, meaning the system
reads or writes data from start to end.
Advantages:
1. Simple to implement and manage.
2.Efficient for tasks that require processing all records in a defined order.
File Organization and Access Mechanism
2. Direct file organization (or random file organization)
Definition: Direct file organization stores records in such a way that
each record is uniquely identified by a key or address.
Access Method: Records are accessed randomly or directly using a key
or address, rather than sequentially
Advantages:
1. Allows for quick access to specific records based on their keys,
without scanning through all preceding records.
2.Efficient for applications requiring frequent updates or retrievals of
specific data items.
File Organization and Access Mechanism
3. Indexed file organization
• Definition: Indexed file organization involves maintaining an index structure
that maps keys to the physical locations of records.
• This index includes key fields along with corresponding pointers or addresses.
• Access Method: Records are accessed randomly through the index, allowing
to specific records using pointer without the need to sequentially read
through preceding records.
• Advantages:
Enables fast access to specific records using indexed pointers, improving
retrieval efficiency.
File Directories
•A file directory is a system used to organize and manage files on a
computer or server.
•It organizes files and folders in a hierarchical manner.
•In other words, directories are like folders that help to organize files on a
computer. Just like you use folders to keep your papers and documents in
order, the operating system uses directories to keep track of files and
where they are stored.
•Directory Structure:
Different Types of Directory
Single-Level Directory
• The entire system contains only one directory.
• This directory lists all files present in the file system.
• No subdirectories are used; all files are at the same level.
• It can become disorganized as the number of files increases.
Different Types of Directory
Two -Level Directory
• In a two-level directory system, a separate directory is created for each
user.
• There is one master directory that contains individual directories for each
user.
• Each user has a dedicated directory at the second level that holds their
files.
• The system restricts users from accessing other users' directories without
permission.
Different Types of Directory
Tree Structured Directory
•In a tree-structured directory system, any directory entry can be either a file
or a subdirectory.
• Similar files can be grouped together in one directory.
•Each user has their own directory and cannot access other users' directories.
•Users can read data from the root directory but cannot write to or modify it
•Only the system administrator has complete access to the root directory.
Different Types of Directory
Acyclic Graph Directory
•Tree-structured directory systems do not allow the same file to exist in
multiple directories.
•This limitation creates concerns regarding file sharing.
•Sharing can be facilitated by using an acyclic graph structure for directories.
•In an acyclic graph, multiple directory entries can point to the same file or
subdirectory.
•This allows the file or subdirectory to be shared between different directory
entries.
File Allocation Methods
1.Contiguous Allocation
•In contiguous allocation, each file occupies a contiguous set of blocks on
the disk.
•If a file requires n blocks and starts at block b, it will be stored in blocks:
b, b+1, b+2, ..., b+n-1.
•The directory entry for a file with contiguous allocation includes:
Address of the starting block.
Length of the allocated portion.
File Allocation Methods
1.Contiguous Allocation
File Allocation Methods
2. Linked List Allocation
•In linked list allocation, each file is stored as a linked list of disk
blocks, which do not need to be contiguous.
•The disk blocks can be scattered anywhere on the disk.
•The directory entry stores pointers to the first and last blocks of
the file.
•Each block contains a pointer to the next block occupied by the file.
File Allocation Methods
2. Linked List Allocation
File Allocation Methods
3. Indexed Allocation
•In this scheme, a special block known as the Index block contains the
pointers to all the blocks occupied by a file.
•Each file has its own index block.
• The ith entry in the index block contains the disk address of the ith file
block.
File Sharing
• File sharing allows public or private sharing of data in a network.
• Accessibility permissions determine who can read, view, or edit the file.
• File sharers can set different levels of authority for access.
• File sharing services typically provide a set amount of storage per user
account.
• Common types of file sharing include:
1. File Transfer Protocol (FTP):
One of the most widely used file transfer methods on the internet.
Allows uploading, accessing, and editing files with proper credentials.
Files are stored on an FTP server, accessible to users via client software.
Some FTP sites allow public access or downloads using a shared
password.
Examples: Cyberduck, FileZilla, Firefox (with add-ons).
File Sharing
2.Peer-to-Peer Networks:
Involves hardware and software for direct communication without a
central server.
Files are stored on individual computers and shared among users.
Example: Instant messaging services like Skype.
3. Removable Storage Media:
Physical media that can be removed from a device or computer.
Users can transfer files to the media and share them physically.
Examples: Memory sticks, optical discs, memory cards, removable hard
disks.
File System Implementation Issues
Few File system implementation issues
• Storage Management – Efficient allocation of disk blocks and tracking
free space.
• Directory Structure – Organizing files in a hierarchy and resolving file
paths.
• Access Control – Managing user permissions and file security.
• Reliability – Making sure data stays safe and correct even if the system
crashes.
• Performance – Improving speed through caching, buffering, and
minimizing fragmentation.
• Metadata Handling – Managing file info like size, timestamps, and
access rights.
• Scalability & Portability – Supporting many files and working across
different systems.
File System Protection and Security
• File system protection and security are critical aspects of operating systems,
ensuring the integrity, confidentiality, and availability of data stored in
computer system.
Data Integrity: Ensures that information is accurate and unaltered, protecting
against corruption and unauthorized changes.
Confidentiality: Protects sensitive data from unauthorized access, ensuring
that only authorized users can view or manipulate the information.
Availability: Guarantees that data and resources are accessible to authorized
users whenever needed, minimizing downtime and ensuring reliable access.
• Following are detailed explanation of various components and strategies
involved.
1. Access Control:
Mechanisms that define who can access specific files and directories.
Often uses permissions to restrict access to authorized users.
Common access control methods include:
File System Protection and Security
• DAC (Discretionary Access Control): The file owner decides who can
access the file.
• MAC (Mandatory Access Control):Access is controlled by the system,
based on security labels or rules.
• RBAC (Role-Based Access Control): Access is given based on the user's
role, like admin or user.
2.Authentication and Authorization:
Authentication: "Processes that verify user identities before
granting access.“
Authorization: "Ensures only authorized users can perform specific
actions on files." only authorized users can perform specific actions
on files.
3. File Integrity Checking:
Techniques that monitor and verify that files remain unchanged.
Often employs checksums or hash functions to detect corruption.
File System Protection and Security
4. Backup:
Strategies for creating copies of data to prevent loss.
Enables recovery in case of hardware failure or accidental
deletion.
5.Audit Trails:
Logs that record users’ activities within the file system.
They provide a way to monitor actions and investigate
security incidents.

You might also like