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

Ch5(Dev,File and System Level Io)

The document discusses storage management in operating systems, focusing on the abstraction of physical storage into logical units called files. It details file attributes, types, structures, and the various operations and mechanisms for file access and management, including space allocation and free-space management. Additionally, it covers device management and I/O subsystem characteristics, emphasizing the importance of I/O scheduling, buffering, and error handling in optimizing system performance.

Uploaded by

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

Ch5(Dev,File and System Level Io)

The document discusses storage management in operating systems, focusing on the abstraction of physical storage into logical units called files. It details file attributes, types, structures, and the various operations and mechanisms for file access and management, including space allocation and free-space management. Additionally, it covers device management and I/O subsystem characteristics, emphasizing the importance of I/O scheduling, buffering, and error handling in optimizing system performance.

Uploaded by

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

Storage

Management
Storage Management
• To make the computer system convenient for users, the operating
system provides a uniform, logical view of information storage.
• The operating system abstracts from the physical properties of its
storage devices to define a logical storage unit, the file.
• The operating system maps files onto physical media and accesses
these files via the storage devices
File
• A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks.
• In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by the
files creator and user.
• Attributes of a File
• Following are some of the attributes of a file :
• Name. It is the only information which is in human-readable form.
• Identifier. The file is identified by a unique tag(number) within file system.
• Type. It is needed for systems that support different types of files.
• Location. Pointer to file location on device.
• Size. The current size of the file.
• Protection. This controls and assigns the power of reading, writing, executing.
• Time, date, and user identification. This is the data for protection, security, and usage
monitoring.
Cont. …
• The operating system is responsible for the following activities in
connection with file management:
• Creating and deleting files
• Creating and deleting directories to organize files
• Supporting primitives for manipulating files and directories
• Mapping files onto secondary storage
• Backing up files on stable (nonvolatile) storage media.
File Structure
• A File Structure should be according to a required format that the
operating system can understand.
• A file has a certain defined structure according to its type.
• A text file is a sequence of characters organized into lines.
• A source file is a sequence of procedures and functions.
• An object file is a sequence of bytes organized into blocks that
are understandable by the machine.
• When operating system defines different file structures, it also contains
the code to support these file structure. Unix, MS-DOS support
minimum number of file structure.
File Type
• File type refers to the ability of the operating system to distinguish
different types of file such as text files source files and binary files etc.
• Many operating systems support many types of files. Operating
system like MS-DOS and UNIX have the following types of files
Ordinary files
• These are the files that contain user information.
• These may have text, databases or executable program.
• The user can apply various operations on such files like add, modify,
delete or even remove the entire file.
Cont. …
Directory files
• These files contain list of file names and other information related to these files.
Special files
• These files are also known as device files.
• These files represent physical device like disks, terminals, printers, networks,
tape drive etc.
• These files are of two types −
Character special files − data is handled character by character as in case of
terminals or printers.
Block special files − data is handled in blocks as in the case of disks and tapes.
File System Implementation
• How exactly are file systems implemented?
• Comes down to: how do we represent
• Volumes
• Directories (link file names to file “structure”)
• The list of blocks containing the data
• Other information such as access control list or permissions, owner, time of
access, etc?
• And, can we be smart about layout?

8
File Control Block
• FCB has all the information about the file
• Linux systems call these i-node structures

9
Implementing File Operations
• Create a file:
• Find space in the file system, add directory entry.
• Open file
• System call specifying name of file.
• system searches directory structure to find file.
• System keeps current file position pointer to the location where next
write/read occurs
• System call returns file descriptor (a handle) to user process
• Writing in a file:
• System call specifying file descriptor and information to be written
• Writes information at location pointed by the files current pointer
• Reading a file:
• System call specifying file descriptor and number of bytes to read
(and possibly where in memory to stick contents).
10
Implementing File Operations
• Repositioning within a file:
• System call specifying file descriptor and new location of current
pointer
• (also called a file seek even though does not interact with disk)
• Closing a file:
• System call specifying file descriptor
• Call removes current file position pointer and file descriptor
associated with process and file
• Deleting a file:
• Search directory structure for named file, release associated file
space and erase directory entry
• Truncating a file:
• Keep attributes the same, but reset file size to 0, and reclaim file
space. 11
File Access Mechanisms
• File access mechanism refers to the manner in which the records of a file may be
accessed.
• There are several ways to access files −
• Sequential access
• Direct/Random access
• Indexed sequential access
Sequential access:
A sequential access is that in which the records are accessed in some sequence, i.e.,
the information in the file is processed in order, one record after the other. This
access method is the most primitive one.
Example: Compilers usually access files in this fashion.
Cont. …
Direct/Random access
• Random access file organization provides, accessing the records directly.
• Each record has its own address on the file with by the help of this
address it can be directly accessed for reading or writing.
• The records need not be in any sequence within the file and they need
not be in adjacent locations on the storage medium.
Indexed sequential access
• This mechanism is built up on base of sequential access.
• An index is created for each file which contains pointers to various blocks.
• Index is searched sequentially and its pointer is used to access the file
directly.
Space Allocation
• Files are allocated disk spaces by operating system. Operating systems
deploy following three main ways to allocate disk space to files.
• Contiguous Allocation
• Linked Allocation
• Indexed Allocation
Contiguous Allocation
• Each file occupies a contiguous address space on disk.
• Assigned disk address is in linear order.
• Easy to implement.
• External fragmentation is a major issue with this type of allocation
technique.
Cont. …
• Linked Allocation
• Each file carries a list of links to
disk blocks.
• Directory contains link / pointer
to first block of a file.
• No external fragmentation
• Effectively used in sequential
access file.
• Inefficient in case of direct
access file.
Indexed Allocation
• Provides solutions to problems of
contiguous and linked allocation.
• A index block is created having all
pointers to files.
• Each file has its own index block
which stores the addresses of disk
space occupied by the file.
• Directory contains the addresses
of index blocks of files.
Free-Space Management
• File system maintains free-space list to track available blocks/clusters
• Four different methods:
• Bit map
• Free list
• Grouping
• Counting
Free-Space Management – bit map
• Bit vector (or bit map) (n blocks)
• This technique is used to implement the free space management. When the
free space is implemented as the bitmap or bit vector then each block of the
disk is represented by a bit.
• When the block is free its bit is set to 1 and when the block is allocated the bit is
set to 0.
• The main advantage of the bitmap is it is relatively simple and efficient in
finding the first free block and also the consecutive free block in the disk.
• Many computers provide the bit manipulation instruction which is used by the
users.
• The calculation of the block number is done by the formula:
• (number of bits per words) X (number of 0-value word) + Offset of first 1 bit
Cont. …
• Assume the following are free. Rest are allocated:

Advantages:
• This technique is relatively simple.
• This technique is very efficient to find the free space on the disk.
Disadvantages:
• This technique requires a special hardware support to find the first 1 in a word it is not 0.
• This technique is not useful for the larger disks.
For example: Consider a disk where blocks 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 17, 18, 25,26, and
27 are free and the rest of the blocks are allocated. The free-space bitmap would be:
001111001111110001100000011100000
Free List
 Linked list (free list)
 Cannot get contiguous space easily
 No waste of space
 No need to traverse the entire list (if # free blocks recorded)

• Advantages:
• Whenever a file is to be allocated a free block, the operating
system can simply allocate the first block in free space list and
move the head pointer to the next free block in the list.
• Disadvantages:
• Searching the free space list will be very time consuming; each
block will have to be read from the disk, which is read very
slowly as compared to the main memory.
• Not Efficient for faster access.
Grouping and Counting
Grouping
• Modify linked list to store address of next n-1 free blocks in first free block, plus a pointer to next
block that contains free-block-pointers
Counting
• Generally, some contiguous blocks are allocated but some are free simultaneously.
• When the free space is allocated to a process according to the contiguous allocation
algorithm or clustering.
• So we cannot keep the list of n free block address but we can keep the address of the first
free block and then the numbers of n free contiguous block which follows the first block.
• When there is an entry in the free space list it consists the address of the disk and a count
variable.
• This method of free space management is similar to the method of allocating blocks.
• We can store these entries in the B-tree in place of the linked list. So the operations like
lookup, deletion, insertion are efficient.
Device management
• Controlling input/output devices is complicated by the wide variety of
devices.
• The variety of different methods used to control these devices
comprise the I/O subsystem.
• This wide variety of devices conflict the push toward the
standardization of interfaces, leading to the use of device driver
modules
Device Management Organization
I/O Hardware
Device Controllers : An Example
• The NEC PD 765 disk controller(Floppy Disk Controller) has a 16
command language, using 1 to 9 bytes in a device register.
• Commands include:
-Reading and writing data
-Moving the disk arm
-Formatting tracks
-Initializing, calibrating, sensing and resetting the controller and its
drives
I/O Port Addresses
Typical I/O Port
• The typical I/O port consists of 4 registers:
–Status –contains bits read by the host system.
–Control –contains bits written by the host system
–Data-in –read by the host as input
–Data-out –written by the host as output
Using Polling To Start An I/O
Operation
Using Interrupts To Start An I/O
Operation
Application I/O Interface
I/O Device Characteristics
Block and Character Devices
• The essential operations of block devices are read, write and seek.
• Raw I/O–accessing a block devices as an array of blocks
• Character-stream devices such as keyboard use the basic operations
get and put.
Blocking and Nonblocking I/O
• When an application calls for input or output, the operating system
blocks the process until the I/O operation is completed. Such a system
call is called a blocking system call.
• Some application cannot work properly if system calls block the
process, e.g., video applications. These use nonblocking system calls.
• Nonblocking I/O requires that execution and I/O occur concurrently.
This can be implemented by writing multithreaded programs.
• An alternative involves nonblocking system calls which do not wait for
I/O to be completed
Kernel I/O Subsystem
• The I/O subsystem provides these services:
• I/O Scheduling
• Buffering
• Caching
• Spooling
• Device Reservation
• Error handling
I/O Scheduling
• The order in which input/output requests are made is rarely the best order
in which to perform them.
• I/O request scheduling algorithms seek to maximize performance while
guaranteeing that all input/output are fulfilled within a reasonable time
frame.
• Caching
• A cache is a copy of input/output data in memory that can be accessed
more quickly than what is stored externally.
• Although buffering and caching are distinct functions, there are cases
where the same area of memory is used for both purposes, e.g., when
reading disk data.
Spooling and Device Reservation
• A spool is a buffer for output intended for a device that cannot accept
interleaved data streams.
• Printers are an example of such devices.
Error Handling
• Operating systems should be able to handle transient hardware errors.
This is usually done by trying the failed operation again.
• I/O system calls return a bit of information that indicates whether the
operation was a success.
• In some cases either the operating system or the hardware itself may
provide more specific information about a failure.
Transforming I/O Requests to Hardware Operations
Performance
• I/O is a major factor in system performance.
• Interrupt handling is computationally expensive; anything that limits it
can increase system performance.
• Network traffic can seriously affect system performance
• Some systems use front-end processor to terminal I/O.
Reading assignment
Read about the following concepts

• Log-structured file system (LFS)


• Distributed file systems (DFS)
• Network file system (NFS)
• Andrew file system (AFS)
• RAID (Redundant Array of Inexpensive Disks)

You might also like