Chapter Two Three
Chapter Two Three
1|Page
LECTURE NOTES
Character Devices: Transfer data one character (byte) at a time. Examples: Keyboards,
mice, serial ports, printers. These are used for sequential, low-volume data streams.
Device Controllers
A device controller is a hardware interface (chip or card) that manages communication between
the device and the system bus. It handles low-level operations like converting digital signals to
mechanical actions (e.g., moving a disk head).
Examples: SATA controllers for HDDs/SSDs, USB controllers for peripherals.
Advantages: Offloads CPU work, supports multiple devices per controller.
Disadvantages: Can become a bottleneck if overloaded; failures affect connected devices.
What is a bus? Classify them in categories.
Interrupts
Interrupts are signals from devices to the CPU indicating an event (e.g., data ready or operation
complete). They allow asynchronous I/O, freeing the CPU for other tasks.
Types:
Hardware Interrupts: From devices (e.g., keyboard press).
Software Interrupts (Traps): From programs (e.g., system calls for I/O).
Advantages: Efficient for unpredictable events; reduces CPU polling overhead.
Disadvantages: Interrupt handling adds context-switching overhead; too many can cause
"interrupt storms."
2|Page
LECTURE NOTES
We experiment this in real-time systems like gaming, interrupts ensure quick response to user
input (e.g., mouse clicks).
Give a real life scenario to describe an interrupt you usually face with related devices such as
your phone.
Give examples of maskable and non-maskable interrupts that exist in the computer system. Use
a table to differentiate them.
3|Page
LECTURE NOTES
Hard Disk Drives (HDD) and Solid State Drives (SSD) are two types of storage devices used to
store data on computers,laptops, and other devices. While HDDs have been around for decades,
SSDs are a newer, faster, and more advanced technology. The main difference between them lies
in how they store and access data. Let's look at the fundamental distinctions between HDD and
SSD.
What is a Hard Disk Drive(HDD)?
An HDD consists of a spinning disk (platter) coated with a magnetic material and a read/write
head that reads and writes data on the disk's surface. The read/write head moves back and forth
across the spinning disk to access different parts of the data stored on the disk. HDDs have been
around for decades and are the more traditional type of storage device.
4|Page
LECTURE NOTES
communication between the HDD and the computer, ensuring data is accessed correctly. Since
HDDs have moving parts, they are slower and can wear out over time compared to Solid State
Drives (SSDs), which have no moving components. However, HDDs remain popular because
they offer large storage capacity at a lower cost.
5|Page
LECTURE NOTES
A Solid State Drive (SSD) stores and retrieves data using flash memory instead of moving parts,
making it much faster and more durable than a traditional Hard Disk Drive (HDD).
SSDs use NAND flash memory chips to store data. When you save a file, electrical charges are
used to store information in tiny memory cells inside these chips. Each cell retains data even
when the power is turned off, allowing the SSD to keep your files permanently. Since SSDs have
no spinning disks or moving read/write heads like HDDs, they can access data almost instantly.
When you open a file or program, the SSD's controller quickly finds the required data and sends
it to the computer. Because SSDs rely on electronic circuits rather than mechanical parts, they
operate silently, use less power, and are more resistant to damage from drops or shocks. Their
speed significantly improves computer performance, making tasks like booting up, loading
applications, and transferring files much faster compared to HDDs.
6|Page
LECTURE NOTES
DMA (Direct Memory Access): A DMA controller transfers data directly between device
and memory, bypassing the CPU. We can experiment this from copying large files from
disk to memory without CPU intervention. It can bring high throughput for bulk
transfers; and it equally frees the CPU entirely. Some drawbacks may be that , it requires
dedicated hardware, it is equally a potential bus contention system. A use case is video
streaming or network packet transfers in high-performance servers.
Single Buffering
7|Page
LECTURE NOTES
This is the simplest type of Buffering where only one system buffer is allocated by the Operating
System for the system to work with. The producer(I/O device) produces only one block of data in
the buffer for the consumer to receive. After one complete transaction of one block of data, the
buffer memory again produces the buffer data.
Double Buffering
This is an upgrade over Single Buffering as instead of using one buffer data here two are used.
The working of this is similar to the previous one, the difference is that the data is first moved to
the first buffer then it is moved to the second buffer. Then retrieved by the consumer end. Here
on one hand the data is inserted into one buffer while the data in the other buffer is processed
into the other one.
Circular Buffering
Double Buffering is upgraded to this, in this process more than two buffers are used. The
mechanism which was used earlier is a bit enhanced here, where one buffer is used to insert the
8|Page
LECTURE NOTES
data while the next one of it used to process the data that was earlier inserted. This chain of
processing is done until the last buffer in the queue and then the data is retrieved from the last
buffer by the consumer. This mechanism is used where we need faster data transfers and more
bulky data is transferred.
Function of Buffering in OS
Synchronization: This process increases the synchronization of different devices that are
connected, so the system's performance also improves.
Smoothening: The input and output devices have different operating speeds and Buffer data
block sizes, this process encapsulates the difference and ensures a smooth operation.
Efficient Usage: Using this processing technique the system overhead and the inefficient usage
of the system resources.
Advantages of Buffering
9|Page
LECTURE NOTES
Buffering significantly reduces the waiting time for a process or application to access a
device in the system
Smoothens the I/O operations between the different devices that are connected to the
system.
Using Buffer number of calls needed for carrying out an operation, so it increases the
overall performance of the system.
Buffering helps cut down on the number of I/O operations that are needed to access the
desired data.
Disadvantages of Buffering
Buffers/Temporary memory that is used to assign data while transferring takes up a lot of
memory in a long process.
Most of the time the exact size of the data going to be transferred is unpredictable so
more memory is assigned for every data and most of the time the extra space goes
wasted.
Due to unpredictability sometimes more data is stored on the Buffer than it can store
which leads to Buffer Overflow and data corruption.
In some situations, Buffers can result in a delay between the read and write of the data in
the memory and the processing of the data.
10 | P a g e
LECTURE NOTES
A RAID controller manages multiple hard drives, making them work together as one system. It
helps improve speed and adds data protection by handling drive failures. Think of it as a smart
manager that boosts performance and keeps your data safe.
1. Hardware-Based:
Uses a dedicated physical controller to manage hard drives. Offers high speed and reliability.
Can work independently from the computer's processor. Often built into the motherboard or as a
separate card. Think of it as a captain managing the drives smoothly.
2. Software-Based:
Uses the computer’s processor and memory to manage RAID. No special hardware needed.
Cost-effective, but may reduce overall system performance. Slower than hardware RAID. Acts
like a helpful assistant, but shares the load with other tasks.
3. Firmware-Based (Fake RAID):
Built into the computer's BIOS/firmware and works during boot-up. Needs a driver after the OS
loads. Cheaper than hardware RAID, but still uses CPU resources. Also known as hybrid RAID
or fake RAID. A startup helper that hands over the job to software once the system runs.
Types of RAID
1. RAID-0 (Stripping)
11 | P a g e
LECTURE NOTES
RAID-0 improves system performance by splitting data into smaller "blocks" and spreading
them across multiple disks. This process is called "striping." It enhances data access speed by
enabling parallel read/write operations but provides no redundancy or fault tolerance.
A set of blocks distributed across the disks forms a "stripe." For instance, "0, 1, 2, 3" is one
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.
Evaluation:
2. RAID-1 (Mirroring)
12 | P a g e
LECTURE NOTES
RAID-1 enhances reliability by creating an identical copy (mirror) of each data block on separate
disks. This ensures that even if one disk fails, the data remains accessible from its duplicate.
While this configuration is highly reliable, it requires significant storage overhead.
Mirroring: Each block of data is written to two (or more) disks. For example:
Block 0 is stored on Disk 0 and its duplicate on Disk 1.
Block 1 is stored on Disk 2 and its duplicate on Disk 3.
Mirroring Level 2: In the figure, "mirroring level 2" indicates that there are two copies of each
block, distributed across different disks. 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 to N/2, If we are lucky enough and disks 0 and 2 fail, then 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:
It covers complete redundancy.
It can increase data security and speed.
Disadvantages:
It is highly expensive.
Storage capacity is less.
RAID-2 is a specialized RAID level that uses bit-level striping combined with error correction
using Hamming Code. In this configuration, data is distributed at the bit level across multiple
drives and a dedicated parity drive is used for error detection and correction. While it offers
strong fault tolerance, its complexity and cost make it rarely used in practice.
Advantages:
In case of Error Correction, it uses hamming code.
It Uses one designated drive to store parity.
Disadvantages:
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.
Evaluation:
Reliability: RAID-3 can tolerate the failure of one disk. The lost data can be
reconstructed using the parity drive and the remaining data drives.
Capacity: Usable Capacity =( N – 1 ) × B =(N−1)× B ,where N is the total number of
drives and B is the number of blocks per drive. The capacity of one drive is reserved for
storing parity information.
14 | P a g e
LECTURE NOTES
Advantages:
Data can be transferred in bulk.
Data can be accessed in parallel.
Disadvantages:
15 | P a g e
LECTURE NOTES
Assume that in the above figure, C3 is lost due to some disk failure. Then, we can recompute 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
Capacity: ( N – 1 ) ∗ B (N−1)∗B, One disk in the system is reserved for storing the parity.
parity works). If more than one disk fails, there is no way to recover the data.
Hence,
( N – 1 ) (N−1) disks are made available for data storage, each disk having B blocks.
Advantages: It helps in reconstructing the data if at most one data is lost.
Disadvantages: It can't help reconstructing data when more than one is lost.
Block-Level Striping: Data is divided into blocks and striped across all drives in the
array.
Distributed Parity: Parity bits, calculated using the XOR function, are distributed across
all drives in a rotating pattern.
Example:
16 | P a g e
LECTURE NOTES
Capacity: ( N – 1 ) ∗ B (N−1)∗B, Overall, space equivalent to one disk is utilized in storing the
identical to RAID-4.
parity. Hence, ( N – 1 ) (N−1) disks are made available for data storage, each disk having B
blocks.
Advantages:
Data can be reconstructed using parity bits.
It makes the performance better.
Disadvantages:
Its technology is complex and extra space is required.
If both discs get damaged, data will be lost forever.
Block-Level Striping: Data is divided into blocks and striped across all disks in the
array.
Double Distributed Parity: Two sets of parity information are calculated for every block
and distributed across all disks in the array in a rotating pattern.
17 | P a g e
LECTURE NOTES
Example:
Evaluation:
Reliability: RAID-6 can tolerate the simultaneous failure of two disks, providing greater
fault tolerance than RAID-5.
Capacity: Usable Capacity = ( N – 2 ) × B (N−2) × B where N is the total number of
disks and B is the number of blocks per disk.
Advantages:
Very high data Accessibility.
Fast read data transactions.
Disadvantages:
Due to double parity, it has slow write data transactions.
Extra space is required.
18 | P a g e
LECTURE NOTES
Interface Layer: High-level operations exposed to users and programs (e.g., via system calls).
Logical Layer: Internal representations like files and directories.
Physical Layer: Actual data placement on storage media.
Use Cases
In cloud storage (e.g., AWS S3), file systems handle distributed data across servers.
In mobile Operating systems like Android, they manage app data isolation.
Inodes (Index Nodes): Metadata structures storing file attributes (e.g., size, timestamps,
permissions) and pointers to data blocks. In ext4 (Linux), each file has an inode with
direct/indirect block pointers. Leads to efficient metadata access, supports sparse files.
What is a parse file?
A drawback maybe Fixed inode count can limit file creation. Applicable in Unix-like systems
for quick attribute lookups.
Directories: Special files containing mappings from names to inodes. A directory entry
(dirent) with filename and inode number. It enables hierarchical organization but leads to
directory fragmentation over time. Applications maybe File explorers like Windows
Explorer.
20 | P a g e
LECTURE NOTES
Single-Level: All files in are in one flat directory. The early MS-DOS with all files at the
root directory. It provies fast and efficient lookup. But equally leads to Name collisions,
difficulty in multiple file management. Embedded systems use this type especially when
they have few files.
Hierarchical (Tree-Structured): Nested directories. A hierarchical tree structure
arranges data in a tree-like format where each node has parent and child nodes, creating a
hierarchy. Hierarchical trees provide a clear and organized way to represent relationships
between different elements of data Example: /home/user/docs/[Link] in Unix. It can
facilitate Logical grouping and equally scalability.
What is scalability?
The hierarchical organization may lead to longer path resolutions and deep nesting issues.
The operating systems we use today like Windows use this for user data organization.
Linked Allocation:
In linked allocation, file blocks are not stored continuously in memory. Instead, each file is
represented as a linked list of disk blocks, where each block contains a pointer to the next block.
This allows the blocks to be scattered across the disk, eliminating the need for contiguous
memory allocation. Each block has a pointer to the next; no contiguous requirement. This is
Flexible and offers no fragmentation waste.
A draw back maybe Pointer overhead and reliability issues if link breaks.
21 | P a g e
LECTURE NOTES
Bitmaps (Bit Vectors): In disk free space management, the bitmap or bit vector approach is
commonly used to track the allocation status of disk blocks. In this method, each block is
represented by 1 bit. A bit value of 0 indicates that the block is free. A bit value of 1 indicates
that the block is allocated. For 1TB disk with 4KB blocks, bitmap is ~32MB.
Advantages maybe Compactness, fast to find free blocks through bit operations.
Drawbacks maybe large bitmaps for big disks scanning for contiguous space is slow.
Very relatable in ext2/3 file systems.
22 | P a g e
LECTURE NOTES
Linked Lists: In this approach, Free blocks are linked together in a list. Each free block stores
the address of the next free block. The list is maintained dynamically as blocks are allocated and
freed.
The Free list head points to first free block. They have no extra space; easy to allocate/deallocate.
They may be Slow to traverse for large free spaces, fragmentation.
Applicable in simple Operating system or memory management.
Boundary Tags
In this approach, Each block contains a boundary tag indicating its size and whether it is free or
occupied. Adjacent free blocks are merged during deallocation to reduce fragmentation. Useful
in memory management systems. Simplifies coalescing of adjacent free blocks. Despite that ,
Slight overhead in storing tag information. It is more complex than bitmap or linked list.
23 | P a g e
LECTURE NOTES
Free List
In this approach, The free blocks are maintained in a list (array or linked list). Each entry in the
free list points directly to a free block on disk.
It offers fast allocation as free blocks are known upfront. Easy to traverse and maintain.
As cons, Extra memory is needed to store the list. May suffer from fragmentation over time
3.5. Specific File Systems: FAT and NTFS
FAT (File Allocation Table) and NTFS (New Technology File System) are two file systems used
by Windows, each with distinct features, advantages, and limitations.
FAT is a simple file system developed by Microsoft in the 1970s, primarily for small disks and
simple folder structures. The most common variant today is FAT32. FAT32 is widely supported
across various operating systems and devices, making it ideal for removable storage like USB
drives and memory cards.
24 | P a g e
LECTURE NOTES
FAT32 stands for File Allocation Table. FAT32 is an extension of previous file systems in which
the data is stored in chunks of 32 bits. FAT32 is an upgraded version of FAT16 designed to
overcome the limitations of FAT16 and add support for larger media. FAT32 was used in older
versions of operating systems like Windows 95 up until Windows XP.
FAT32 is the original file system for the Windows operating system, having been developed in
the 1970s. It was mainly made for floppy drives with capacities less than 500 K. Each of the
three FAT file systems—FAT12, FAT16, and FAT32—has a different file size and disc layout.
Initially, MS-DOS used the FAT file system, with a maximum hard drive size of 32 MB and
sectors partitioned into 512 K. It frequently appears in removable discs and storage devices. A
FAT32 drive's maximum file size is limited to 4 GB, while the size of a FAT32 partition cannot
exceed 8 TB. The lack of security offered by FAT32 is its primary drawback. File access
protection is absent from FAT16, the prior version of the file system, and thus suffers from
internal fragmentation.
25 | P a g e
LECTURE NOTES
26 | P a g e
LECTURE NOTES
NTFS
NTFS stands for New Technology File System. First introduced in 1993, it is used in newer
versions of operating systems such as Windows NT and 2000 and later versions of Windows.
NTFS is a more robust, high-performance logging file system with multi-user access control,
ACLs, and many other things that make it appropriate to work with an Operating System that has
protection. NTFS includes characteristics such as data recovery, multi-streaming, fault tolerance,
security, extended file size, and file systems, UNICODE names. exFAT is used where NTFS is
not feasible, due to its data-structure overhead, but a greater file-size limit than the standard
FAT32 file system is needed.
Features of NTFS
Advanced Features: NTFS is a feature-rich file system designed to meet the needs of modern
computing environments. It supports features including record compression, encryption, disk
quotas, symbolic links, and document system journaling, imparting greater flexibility and
capability compared to FAT32.
Dynamic Disk Support: NTFS supports dynamic disks, which allows for superior disk
management capabilities consisting of software RAID (Redundant Array of Independent Disks).
Sparse File Support: Sparse documents are used in programs along with digital machines and
database systems to effectively allocate garage space for facts this is in general empty.
Transaction Support: NTFS helps transactions, permitting a couple of report machine
operations to be grouped together as a single atomic transaction. This ensures statistics integrity
and consistency, specially in situations where more than one operations want to be done together
(e.G., database transactions).
Improved Security: NTFS presents sturdy security features, which includes file and folder
permissions, get right of entry to access control lists (ACLs), and encryption.
27 | P a g e
LECTURE NOTES
Advantages of NTFS
NTFS is highly secure because it prevents unauthorized access to file contents by enforcing
Encryption File System(EFS).
NTFS performs well even in the partitions of size over 400 MB.
NTFS is less susceptible to fragmentation.
NTFS offers faster processing and is more stable than FAT32. File attributes can also be
classified as resident or non-resident. While the non-resident features are maintained outside of
MFT, the resident characteristics are retained within MFT. When Windows starts, the MFT is
loaded and all properties are retained if the file is less than 1KB.
Physical and logical disc issues may be automatically fixed by the NTFS file system. The sector
is checked before every read and write operation. Any mistakes that arise while reading will be
reported. If an issue arises during writing the data, it will choose the appropriate sector to write
the data in. Additionally, it will highlight the damaged area so you don't use it again.
Disadvantages of NTFS
NTFS is not extensively supported.
Performance in the NTFS file system degrades under partitions of 400 MB.
It takes a lot of extra space for the NTFS file system to function. "Space overhead" is the term
for the data storage used by the file system itself; this data storage is not meant to hold other
kinds of data. Therefore, if you format a drive that uses the NTFS file system, you will lose some
storage capacity.
One of the main problems with the NTFS file system is that it is incompatible. Windows 2000
and later operating system versions are compatible with it. Windows versions prior to this one
are not compatible.
File naming is subject to several limitations. The maximum character count for the directory and
file names is 255. The system does not distinguish between lowercase and uppercase letters, even
though file names may contain capital letters.
Because of the required space overhead, a floppy disc cannot be formatted using the NTFS file
system. Floppy disc drives are widely used in older Windows-based computers.
Without the aid of third-party software, Mac computers are unable to write data on NTFS
formatted storage.
28 | P a g e
LECTURE NOTES
29 | P a g e