PDF_OS Module 6
PDF_OS Module 6
• The OS uses I/O scheduling algorithms to optimize the order in which I/O requests
are handled.
• Scheduling helps avoid long wait times and optimizes throughput.
• Common scheduling algorithms:
o FCFS (First Come, First Serve): Processes requests in the order they arrive.
o SSTF (Shortest Seek Time First): Prioritizes the request closest to the current
head position.
o SCAN (Elevator Algorithm): Moves in one direction, fulfilling requests, then
reverses direction.
D. Interrupt Handling
• Interrupts signal the CPU that an I/O device needs attention.
• The OS uses Interrupt Service Routines (ISRs) to handle interrupts efficiently.
• Steps in interrupt handling:
1. Device sends an interrupt signal.
2. The CPU suspends current operations.
3. The OS executes the corresponding ISR.
4. After handling, the CPU resumes previous operations.
E. Memory-Mapped I/O (MMIO)
• Some systems use Memory-Mapped I/O to communicate with devices.
• Device control registers are mapped into the system’s address space.
• The OS accesses them like regular memory locations, which simplifies I/O operations.
F. Direct Memory Access (DMA)
• DMA is a technique where I/O devices directly access system memory without
involving the CPU.
• Benefits:
o Reduces CPU overhead.
o Improves I/O performance for large data transfers.
• Used by high-speed devices like hard drives and graphics cards.
Operating systems and input/output devices must interact in order to ensure the smooth
operation of a computer system and user accessibility for a variety of reasons, each with a
distinct purpose.
Input and Output: I/O devices let users provide the operating system input and receive output
from it. Users can issue commands, engage with programs, and traverse the system via input
devices such as keyboards and mice. The user gets information, results, or visual feedback
through output devices like monitors and printers. Users are able to successfully employ the
features of a computer system through seamless interaction facilitated by communication
between the operating system and peripheral devices.
Device Control and Configuration: The operating system must communicate with I/O
devices in order to regulate and control their behavior. This includes actions such as configuring
device settings, initializing devices during system startup, assigning system resources such as
interrupts or memory, and managing power states. The operating system can guarantee that the
devices are correctly set up and working inside the system environment thanks to this
communication. devices.
Data Transfer and Storage: Modern operating systems would struggle to move or store any
kind of digital data without I/O components like hard drives or solid-state drives (SSDs). These
crucial parts help with the process by establishing efficient lines of communication between
your computer’s CPU and motherboard AND storing relevant data such as files, programs,
systems, and data, enabling you to have seamless access due to their speedy reading and writing
capabilities. When working on or saving any type of digital information imaginable, lag-free
performance is ensured by this cooperation between the OS and I/O device.
Peripheral Device Support: Support for numerous peripherals and external hardware
elements is provided via I/O devices. Data exchange through local networks or the internet is
made possible, for instance, by network adapters, which provide the operating system access
to other computers or network devices. Similar to that, USB ports enable the connection of
extra devices including storage devices, printers, scanners, and cameras. The operating system
may make use of these peripherals’ capabilities and offer a smooth user experience by
communicating with them.
System Monitoring and Control: Efficient monitoring and management of diverse system
operations require an operating system to interface with specific I/O devices. To maintain the
optimal health of a functioning computer ecosystem while making necessary modifications,
sensors within the hardware or external mechanisms collect data on various environmental
parameters like temperature and voltage. Moreover, effective scheduling of tasks and smooth
time management is facilitated by intercommunication with complementary components such
as a real-time clock or a standard clock.
• The I/O bus from the processor is attached to all peripheral interfaces.
• To communicate with the particular devices, the processor places a device address on
the address bus.
• Each interface contains an address decoder that monitors the address line. When the
interface detects the particular device address, it activates the path between the data line
and devices that it controls.
• At the same time that the address is made available in the address line, the processor
provides a function code in the control way includes control command, output data and
input data.
The OS uses logical disk organization to map physical disk addresses into a logical structure
for file storage and retrieval.
A. Disk Partitions
• A physical disk is divided into partitions, which the OS treats as separate logical disks.
• Each partition has its own file system.
• Types of partitions:
o Primary Partition: The main, bootable partition.
o Extended Partition: Used to create multiple logical drives.
o Logical Partition: A section within an extended partition.
B. File System Organization
• The file system manages how data is stored, organized, and accessed on the disk.
• It uses inodes, directories, and file allocation tables (FAT) to map files to disk blocks.
• Common file systems:
o FAT32 (Windows)
o NTFS (Windows)
o ext3/ext4 (Linux)
o APFS (MacOS)
C. Disk Addressing:
• The OS uses Logical Block Addressing (LBA) to access disk blocks.
• LBA: Converts the cylinder, head, and sector (CHS) address into a single logical
address.
• Simplifies disk access by treating the disk as a linear array of blocks.
o May result in long waiting times for requests at the end of the queue.
D. C-SCAN (Circular SCAN)
• Similar to SCAN but only moves in one direction, then jumps back.
• Advantages:
o Provides uniform wait time.
• Disadvantages:
o Higher seek time compared to SCAN.
E. LOOK Algorithm
LOOK is a modified version of SCAN. Instead of going to the end of the disk, the head only
goes as far as the last request in each direction, then reverses.
Advantages:
• Reduces unnecessary movements compared to SCAN.
• Prevents starvation.
Disadvantages:
• Seek time depends on the direction of travel.
First-Come-First-Serve (FCFS):
Execution Order:
53 → 98 → 183 → 37 → 122 → 14 → 124 → 65 → 67
Head Movement Calculation:
|53 - 98| = 45
|98 - 183| = 85
|183 - 37| = 146
|37 - 122| = 85
|122 - 14| = 108
|14 - 124| = 110
|124 - 65| = 59
|65 - 67| = 2
LOOK Algorithm:
Execution Order:
53 → 65 → 67 → 98 → 122 → 124 → 183 → (reverse) → 37 → 14
Head Movement Calculation:
|53 - 65| = 12
|65 - 67| = 2
|67 - 98| = 31
|98 - 122| = 24
|122 - 124| = 2
|124 - 183| = 59
|183 - 37| = 146
|37 - 14| = 23