0% found this document useful (0 votes)
24 views14 pages

Unit 4

operating system unit-4 ppt

Uploaded by

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

Unit 4

operating system unit-4 ppt

Uploaded by

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

21AD201-OPERATING

SYSTEM PRINCIPLES

1
UNIT-4

I/O SYSTEMS

2
File Concept
– File Attributes:
• Name, Identifier, Type, Location, Size, Protection, Timestamps and
User Identification
– File Operations
• Creating, Opening, Writing, Reading, Repositioning within file,
Deleting, Truncating
– File Structure
• Contiguous allocation: This structure stores a file as a contiguous
block of data on the storage device. It is simple and efficient but can
lead to fragmentation as files are added, deleted, and modified.
• Linked allocation: This structure stores a file as a linked list of data
blocks on the storage device.
• Indexed allocation: This structure uses an index to store the
addresses of the data blocks that make up a file.
• Combined allocation: This structure combines elements of both
contiguous and linked allocation to provide a more efficient
solution. 3
Access Methods
– Sequential Access: In this method, data is accessed in a sequential manner,
i.e., the computer reads data from the beginning of a file or storage device
and continues to read data until it reaches the end of the file. This method is
commonly used for reading data from tapes.
– Direct Access: This method allows the computer to read data from any point
in a file or storage device. With direct access, the computer can jump directly
to the desired location and retrieve the data, rather than having to read all the
data in sequence. This method is commonly used for reading data from hard
disk drives.
– Random Access: This method allows the computer to access any location in
a storage device directly and quickly. Random access is used in memory
devices such as RAM and cache, where data can be accessed in any order.
– Indexed Access: This method involves the use of an index to locate data
within a file or storage device. An index is a data structure that contains
pointers to the locations of data in the file. This method is commonly used
for reading data from databases.
4
Directory structure
– Single-level directory structure: In this structure, all files are stored in a
single directory. This approach is simple but can become unmanageable
when the number of files grows.
– Two-level directory structure: This structure uses a root directory to
contain multiple user directories. Each user directory can then contain its
own set of files. This approach is more organized than a single-level
directory structure but can still become difficult to manage as the number
of users and files increases.
– Hierarchical directory structure: This structure uses a tree-like hierarchy
of directories to organize files. Each directory can contain its own set of
files or subdirectories, creating a logical organization of files. This
approach is used in most modern operating systems.
– Indexed directory structure: This structure uses an index to organize files.
The index contains pointers to the data, allowing the system to quickly
access specific files without having to scan the entire directory.
– Virtual file system: A virtual file system is a file structure that provides an
interface for accessing different types of files and storage devices. This
allows the operating system to manage all file types and storage devices 5
using a single file structure.
File-System Structure
– A file system is a way of organizing and storing files on a storage device,
such as a hard disk drive or solid-state drive.
• Hierarchical File System: Files are organized in a hierarchical tree-like
structure, with the root directory at the top and subdirectories branching off
from there.
• Flat File System: In this file system structure, files are stored in a single
directory without any subdirectories.
• Network File System: This file system structure allows multiple computers to
access and share files over a network. The files are stored on a central server,
and users can access them from any computer connected to the network.
• Distributed File System: This file system structure allows files to be stored
across multiple servers in a network. The files are distributed across the
servers, and users can access them as if they were stored on a single server.
• Journaling File System: This type of file system is designed to prevent data
loss in the event of a system crash or power failure.
6
File system mounting
– File system mounting is the process by which a file system is
made available to the operating system and applications for use.
– It involves specifying the device or partition where the file
system resides and the mount point, which is the location in the
file system hierarchy where the file system is to be attached.
– Mounting a file system can be done manually or automatically
by using configuration files or scripts.
– Unmounting a file system involves detaching it from the mount
point and making it unavailable for use.
– This is typically done by using the umount command, which
flushes any cached data and metadata from the file system
before detaching it.
7
Directory Implementation
– Linear List: In this implementation, directories are stored as a linear list of
names with pointers to the files or subdirectories. The main disadvantage of
this method is that searching for a specific file or directory can be slow as
the entire list must be searched.
– Hash Table: This implementation uses a hash table to store directory entries.
Each entry in the hash table corresponds to a file or directory, and the hash
value is used to quickly locate the entry. The advantage of this method is
that searching for a specific file or directory is fast.
– Binary Tree: In this implementation, directories are stored as a binary tree,
with each node representing a directory and its subdirectories. The
advantage of this method is that searching for a specific file or directory is
faster than a linear list, but slower than a hash table.
– Acyclic Graph: In this implementation, directories are stored as an acyclic
graph, with each node representing a directory and its subdirectories. The
advantage of this method is that it can represent complex directory
structures, but the disadvantage is that searching for a specific file or
directory can be slower than other methods.
8
Allocation Methods
– Contiguous Allocation: In this method, files are stored in contiguous blocks
of disk space. When a file is created, the operating system finds a large
enough contiguous block of free space and assigns it to the file. The
advantage of this method is that it is simple and efficient, but the
disadvantage is that it can lead to fragmentation as files are created and
deleted.
– Linked Allocation: In this method, files are stored as a linked list of blocks.
Each block contains a pointer to the next block in the file. When a file is
created, the operating system assigns it a series of blocks scattered
throughout the disk. The advantage of this method is that it can handle files
of any size and is not subject to fragmentation. However, it is slower than
contiguous allocation because each block must be read sequentially.
– Indexed Allocation: In this method, a master index block is used to keep
track of the location of each file's blocks on the disk. When a file is created,
the operating system assigns it a unique index block, which contains
pointers to each block of the file. The advantage of this method is that it
allows for random access to the file, but it requires more disk space than
linked allocation 9
Free-Space Management
– Bit vector: This is a simple method where a bit vector is used to keep track of
free and used blocks on a disk. Each block is represented by a bit in the
vector, and a value of 1 indicates that the block is used, while a value of 0
indicates that the block is free. The advantage of this method is that it is
simple and efficient, but it can waste space in the bit vector itself.
– Linked list: In this method, a linked list is used to keep track of free blocks.
Each free block contains a pointer to the next free block on the disk. When a
block is allocated for a file, it is removed from the linked list. The advantage
of this method is that it is efficient and can handle variable-sized blocks, but
it can lead to fragmentation.
– Grouping: In this method, free blocks are grouped into clusters. The cluster
size is chosen so that it is larger than the average file size but smaller than the
disk block size.
– Counting: When a block is allocated, the count for that block size is
decremented, and when a block is freed, the count is incremented. This
method reduces external fragmentation and can handle variable-sized blocks,
but it can be complex to implement.
10
Disk scheduling
• The operating system is responsible for using hardware efficiently — for the
disk drives, this means having a fast access time and disk bandwidth.
• Access time has two major components
– Seek time is the time for the disk are to move the heads to the cylinder
containing the desired sector.
– Rotational latency is the additional time waiting for the disk to rotate the
desired sector to the disk head.
• Minimize seek time
• Seek time  seek distance
• Disk bandwidth is the total number of bytes transferred, divided by the total
time between the first request for service and the completion of the last
transfer.

11
Selecting a Disk-Scheduling
Algorithm
• SSTF is common and has a natural appeal
• SCAN and C-SCAN perform better for systems that place a
heavy load on the disk.
• Performance depends on the number and types of requests.
• Requests for disk service can be influenced by the file-
allocation method.
• The disk-scheduling algorithm should be written as a
separate module of the operating system, allowing it to be
replaced with a different algorithm if necessary.
• Either SSTF or LOOK is a reasonable choice for the default
algorithm.
12
Disk Management
• Low-level formatting, or physical formatting — Dividing a disk
into sectors that the disk controller can read and write.
• To use a disk to hold files, the operating system still needs to
record its own data structures on the disk.
– Partition the disk into one or more groups of cylinders.
– Logical formatting or “making a file system”.
• Boot block initializes system.
– The bootstrap is stored in ROM.
– Bootstrap loader program.
• Methods such as sector sparing used to handle bad blocks.

13
Swap-Space Management
• Swap-space — Virtual memory uses disk space as an extension of
main memory.
• Swap-space can be carved out of the normal file system, or, more
commonly, it can be in a separate disk partition.
• Swap-space management
– 4.3BSD allocates swap space when process starts; holds text
segment (the program) and data segment.
– Kernel uses swap maps to track swap-space use.
– Solaris 2 allocates swap space only when a page is forced out
of physical memory, not when the virtual memory page is first
created.

14

You might also like