Professional Documents
Culture Documents
Unit5_OS
Unit5_OS
Operating Systems
ACSE0403A
Unit 5
Directory and Directory Structure, File System: File concept, File Access Mechanism:
- Sequential Access, Direct Access and Index Access methods, File Allocation
Method: Contiguous, Linked and Indexed, Free Space Management: -Bit Vector,
Linked List, Grouping and Counting File System Implementation Issues, File System
Protection and Security, RAID.
Course outcome: After completion of this course students will be able to:
CO5 Understand and analyze the I/O management and File systems K2, K4
ACSE0403A .1 3 3 2 2 1 2 - 2 3 2 2 3
ACSE0403A .2 3 3 3 2 2 3 - 2 3 1 1 3
ACSE0403A .3 3 3 2 2 2 2 - 2 2 3 1 3
ACSE0403A .4 3 2 2 3 1 2 - 1 2 1 2 3
ACSE0403A .5 3 1 2 2 2 2 - 1 2 2 2 3
Average 3 2.4 2.2 2.2 1.6 2.2 - 1.8 2.2 1.8 1.6 3
ACSE0403A .1 2 1 2 2
ACSE0403A .2 2 2 1 2
ACSE0403A .3 2 3 3 2
ACSE0403A .4 2 2 1 2
ACSE0403A .5 2 2 2 2
Average 2 2 1.8 2
• PEO1:Apply sound knowledge in the field of information technology to fulfill the needs of IT
industry.
• PEO2:Design innovative and interdisciplinary systems through latest digital technologies.
• PEO3:Inculcate professional – social ethics, team work and leadership for serving the
society.
• PEO4:Inculcate lifelong learning in the field of computing for successful career in
organizations and R&D sectors.
• https://www.youtube.com/playlist?list=PLmXKhU9FNesSFvj6gASuWmQd23Ul5omtD
CO5: Understand and analyse the I/O management and File systems
OPERATING SYSTEM(ACSE0403A)
CODE PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
ACSE0403A.4
ACSE0403A.5
Course Topics
Outcome Module 1 Module 2 Module 3 Module 4
ACSE0403A.4 3 2 2 2 2 1
RAID CO5
11 May 2023 Nisha ACSE0403A OS Unit 5 34
Topic Objectives
Topic Objective
Students will be able to
I/O Management and Disk Scheduling: Understand the basic Input and output h/w devices and
buffering techniques .
• I/O devices are very important in the computer systems. They provide users the means of interacting
with the system. So there is a separate I/O system devoted to handling the I/O devices.
• I/O Hardware
• There are many I/O devices handled by the operating system such as mouse, keyboard, disk drive etc.
• There are different device drivers that can be connected to the operating system to handle a specific
device.
• The device controller is an interface between the device and the device driver.
• Devices usually have registers where device driver places commands, addresses,
and data to write, or read data from registers after command execution
• Data-in register, data-out register, status register, control register
• Typically 1-4 bytes, or FIFO buffer
• Devices have addresses, used by
• Memory-mapped I/O
• Device data and command registers mapped to processor address space
• Especially for large address spaces (graphics)
• The buffer is an area in the main memory used to store or hold the data temporarily.
• The act of storing data temporarily in the buffer is called buffering.
• A buffer may be used when moving data between processes within a computer. Buffers can be
implemented in a fixed memory location in hardware or by using a virtual data buffer in software,
pointing at a location in the physical memory.
• In all cases, the data in a data buffer are stored on a physical storage medium.
Single Buffer
In Single Buffering, only one buffer is used to transfer the data between two devices. The producer
produces one block of data into the buffer. After that, the consumer consumes the buffer. Only when the
buffer is empty, the processor or producer again produces the data.
In Double Buffering, two schemes or two buffers are used in the place of one. In this buffering, the
producer produces one buffer while the consumer consumes another buffer simultaneously. So, the
producer not needs to wait for filling the buffer. Double buffering is also known as buffer swapping.
circular Buffering
When more than two buffers are used, the buffers' collection is called a circular buffer. Each buffer
is being one unit in the circular buffer. The data transfer rate will increase using the circular buffer
rather than the double buffering.
• An I/O port usually consists of four different registers. These are (1) status, (2) control, (3) data-
in, and (4) data-out registers.
• The data-in register is read by the host for getting input.
• The data-out register is written by the host for sending output.
• The status register holds bits which can be read by the host.
• The control register is written by the host for starting a command or for changing the mode of
any device.
• The data registers are usually 1 to 4 bytes in size. Some of the controllers have FIFO chips which
hold several bytes of input or output data for expanding the capacity of the controller beyond
the size of the data register.
• Bypasses CPU to transfer data directly between I/O device and memory
• Block I/O
• Network sockets
• Unix ioctl() call to send arbitrary bits to a device control register and
data to device data register
File mapped to virtual memory and clusters brought via demand paging
• DMA
• Disk drives are addressed as large 1-dimensional arrays of logical blocks, where the
logical block is the smallest unit of transfer.
• The 1-dimensional array of logical blocks is mapped onto the sectors of the disk
sequentially.
–Sector 0 is the first sector of the first track on the outermost cylinder.
–Mapping proceeds in order through that track, then the rest of the tracks in that
cylinder, and then through the rest of the cylinders from outermost to innermost.
• seek time: time to position heads on cylinder (a fixed head disk does not require seek time
but is more expensive than a moving-head disk)
• rotational latency: delay in accessing material once seek accomplished (time required to wait
for data to rotate around under head)
• Transmission time: time to transfer information once it is under the head.
• access time = seek time + rotational latency
+read/write transmission time
seek time >> read/write time
• The operating system is responsible for using hardware efficiently — for the disk drives,
this means having a fast access time and disk bandwidth.
–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.
• Accomplish this by minimizing seek time
–Seek time approximates seek distance
• Simplest form
• First-come, first-served scheduling
• Requests served in order of arrival
• Advantage: simple queueing
• Disadvantage: does not provide the “best” seek time
•The disk arm starts at one end of the disk, and moves toward the other end, servicing requests
until it gets to the other end of the disk, where the head movement is reversed and servicing
continues
3. The heads of the magnetic disk are attached to a _____ that moves all the heads as a unit.
a) spindle
b) disk arm
c) track
•Arm only goes as far as the last request in each direction, then reverses direction
immediately, without first going all the way to the end of the disk
•SSTF is common and has a natural appeal for low load disks (quickly go to next request)
•LOOK, C-LOOK, SCAN and C-SCAN perform better for systems that place a heavy load on the disk (no
starvation, more predictable delays)
•Performance depends on the number and types of requests
•Requests for disk service can be influenced by the
file-allocation method
•Low-level formatting, or physical formatting — Dividing a disk into sectors that the disk controller
can read and write
•Each sector can hold header information, plus data, plus error correction code (ECC)
•Usually 512 bytes of data but can be selectable
•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, each treated as a logical disk
•Logical formatting or “making a file system”
•To increase efficiency most file systems group blocks into clusters
•Disk I/O done in blocks
•File I/O done in clusters of blocks
•Raw disk access for apps that want to do their own block management, keep OS out of the
way (databases for example)
•Boot block initializes system
•The bootstrap is stored in ROM
•Bootstrap loader program stored in boot blocks of boot partition
•Methods such as sector sparing used to handle bad blocks
4. In the ______ algorithm, the disk arm starts at one end of the disk and moves toward the other
end, servicing requests till the other end of the disk. At the other end, the direction is reversed
and servicing continues.
a) LOOK
b) SCAN
c) C-SCAN
d) C-LOOK
• Directory can be defined as the listing of the related files on the disk. The directory may
store some or the entire file attributes.
• To get the benefit of different file systems on the different operating systems, A hard disk
can be divided into the number of partitions of different sizes. The partitions are also
called volumes or mini disks.
• Each partition must have at least one directory in which, all the files of the partition can
be listed. A directory entry is maintained for each file in the directory which stores all the
information related to that file.
The simplest method is to have one big list of all the files on the disk. The entire system will
contain only one directory which is supposed to mention all the files present in the file system.
The directory contains one entry per each file present on the file system.
Characteristics :
If the sizes of the files are very small then the searching becomes faster.
• File creation, searching, deletion is very simple since we have only one directory.
• We cannot have two files with the same name.
• The directory may be very big therefore searching for a file may take so much time.
• Protection cannot be implemented for multiple users.
• There are no ways to group same kind of files.
• Choosing the unique name for every file is a bit complex and limits the number of files in the system
because most of the Operating System limits the number of characters used to construct the file
name.
In two level directory systems, we can create a separate directory for each user. There is one master
directory which contains separate directories dedicated to each user. For each user, there is a different
directory present at the second level, containing group of user's file. The system doesn't let a user to
enter in the other user's directory without permission.
Characteristics :
• Each file has a path name as /User-name/directory-name/
• Different users can have the same file name.
• Searching becomes more efficient as only one user's list needs to be traversed.
• The same kind of files cannot be grouped into a single directory for a particular use
• In Tree structured directory system, any directory entry can either be a file or sub
directory. Tree structured directory system overcomes the drawbacks of two level
directory system. The similar kind of files can now be grouped in one directory.
• Each user has its own directory and it cannot enter in the other user's directory. However,
the user has the permission to read the root's data but he cannot write or modify this.
Only administrator of the system has the complete access of root directory.
• Searching is more efficient in this directory structure. The concept of current working
directory is used. A file can be accessed by two types of path, either relative or absolute.
•Types:
•Data File “interpretation” is up to user/program
•Numeric (text, ASCII; “LINE_MAX” bytes)
•Character (text, ASCII; “LINE_MAX” bytes)
•Binary (executable, readable by computer)
•Program
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
structures. Unix, MS-DOS support minimum number of files.
• Time, date, and user identification – data for protection, security, and usage monitoring
• Information about files are kept in the directory structure, which is maintained on the disk
• Close (Fi) – move the content of entry Fi in memory back to directory structure on disk
• Sequential Access
read next
write next
reset
skip forward
• Direct Access
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
• If a file can be sorted on any of the filed then an index can be assigned to a group of certain records.
However, A particular record can be accessed by its index. The index is nothing but the address of a
record in the file.
• In index accessing, searching in a large database became very quick and easy but we need to have
some extra space in the memory to store the index value.
Contiguous allocation :
•each file occupies set of contiguous blocks
•Provides efficient direct access.
•Simple – only starting location (block #) and length (number of blocks) are required
•Both sequential and direct access can be supported
•First fit and best fit are the most common used strategies.
•External fragmentation can be a problem
•Best performance in most cases
•Problems include finding space for file, knowing file size, external fragmentation, need for
compaction ,off-line (downtime) or on-line.
• Allocate blocks as needed as the file grows, wherever they are available on the disk
• The directory contains a pointer to the first and last blocks of the file.
• Each block contains a pointer to the next block (not accessible by users)
• No external fragmentation. Any free block can be used to satisfy a request for more space.
• Creating a file is easy, declared of size zero (null pointer to the first block) then grow easily
• Use of clusters (a set of blocks which the system deals with as a unit)
• Each file has its own index block, which is an array of disk-block addresses
• The directory contains the address of the index block, from which the ith block can be accessed
directly
• No external fragmentation. Any free block can be used to satisfy a request for more space.
• Suffers from a wasted space due to the use of index block. (pointer overhead is larger)
• How large the index block should be? What if a file is too large for one index block?
• Linked scheme: use one block. To allow larger files, link several index blocks
• Multilevel index: use a first-level index block to point to a second-level index blocks
1 block[i] free
bit[i] = CPUs have instructions
0 block[i] occupied to return offset within
word of first “1” bit
• 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 (like this one)
• Counting
– Keep address of first free block and count of following free blocks.
– Free space list then has entries containing addresses and counts
• In this approach, the free space list is implemented as a bit map vector. It contains
the number of bits where each bit represents each block.
• If the block is empty then the bit is 1 otherwise it is 0. Initially all the blocks are
empty therefore each bit in the bit map vector contains 1.
• LAs the space allocation proceeds, the file system starts allocating blocks to the files
and setting the respective bit to 0.
• It is another approach for free space management. This approach suggests linking
together all the free blocks and keeping a pointer in the cache which points to the
first free block.
• Therefore, all the free blocks on the disks will be linked together with a pointer.
Whenever a block gets allocated, its previous free block will be linked to its next
free block.
• Trap Door
A trap door is a security breach that may be present in a system
without the knowledge of the users. It can be exploited to harm the data or files
in a system by malicious people.
• Worm
A worm can destroy a system by using its resources to extreme levels. It
can generate multiple copies which claim all the resources and don't allow
any other processes to access them. A worm can shut down a whole network in
this way.
• Denial of Service
These type of attacks do not allow the legitimate users to access a
system. It overwhelms the system with requests so it is overwhelmed and
cannot work properly for other user
• The different methods that may provide protect and security for different computer systems are −
• Authentication
This deals with identifying each user in the system and making sure they are who they
claim to be. The operating system makes sure that all the users are authenticated before they
access the system. The different ways to make sure that the users are authentic are:
• Username/ PasswordEach user has a distinct username and password combination and they need
to enter it correctly before they can access the system.
• User Key/ User CardThe users need to punch a card into the card slot or use they individual key
on a keypad to access the system.
• User Attribute IdentificationDifferent user attribute identifications that can be used are
fingerprint, eye retina etc.
•RAID within a storage array can still fail if the array fails, so automatic replication of the data
between arrays is common
•Frequently, a small number of hot-spare disks are left unallocated, automatically replacing a
failed disk and having data rebuilt onto them
• https://www.youtube.com/watch?v=aKmuGwHj3Cw
• https://www.youtube.com/playlist?list=PLmXKhU9FNesSFvj6gASuWmQd23Ul5omtD
• https://www.youtube.com/watch?v=Fizc0nXRm2g
• https://www.youtube.com/watch?v=RgYU5r9A5TU
• https://nptel.ac.in/courses/106108101
1. In the ______ algorithm, the disk arm starts at one end of the disk and moves toward
the other end, servicing requests till the other end of the disk. At the other end, the
direction is reversed and servicing continues.
A. LOOK
B. SCAN
C. C-SCAN
D. C-LOOK
2. In the sequential access method, information in the file is processed ____________
A. one disk after the other, record access doesnt matter
B. one record after the other
C. one text document after the other
D. none of the mentioned
A. secondary storage
B. main memory
C. tertiary storage
D. none of the mentioned
7. Consider a disk queue with requests for I/O to blocks on cylinders 98 183 37 122 14
124 65 67
Considering FCFS (first come first served) scheduling, the total number of head
movements is, if the disk head is initially at 53 is?
A. 600
B. 620
C. 630
D. 640
8. Data cannot be written to secondary storage unless written within a ______
A. File
B. swap space
C. directory
D. text format
10. In the ______ algorithm, the disk arm goes as far as the final request in each direction,
then reverses direction immediately without going to the end of the disk.
A. LOOK
B. SCAN
C. C-SCAN
D. C-LOOK
A. All files are contained in different directories all at the same level
B. All files are contained in the same directory
C. Depends on the operating system
D. None of the mentioned
5. The three major methods of allocating disk space that are in wide use are
_____________
A. Contiguous
B. Linked
C. Indexed
D. all of the mentioned
A. Supports
B. does not support
C. is not related to
D. none of the mentioned
10. 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. Then the free space bitmap would be
_____________
A. 10000110000001110011111100011111…
B. 110000110000001110011111100011111…
C. 01111001111110001100000011100000…
D. 001111001111110001100000011100000
2. In __________ disk scheduling algorithm, the disk head moves from one end to other
end of the disk, serving the requests along the way. When the head reaches the other end,
it immediately returns to the beginning of the disk without serving any requests on the
return trip.
4. If a process needs I/O to or from a disk, and if the drive or controller is busy then
____________
https://drive.google.com/drive/folders/1UPXvZ7NY09OunSLrEkTFWpw_M3xLzjhs?usp=sharing
1. What are the different file organizations? Discuss access mechanisms in detail.
2. Discuss FCFS, CSCAN, LOOK and CLOOK disk scheduling algorithms with
example.
5. Suppose the moving head disk with 300 cylinders is currently serving a request at track
47 and has just finished a request track 63. If the queue of request is kept in FIFO
order58,37,148,90,97,193,225,24. Explain are total head movements for the following Disk
scheduling algorithm?
i. FCFS ii. SSTF iii. C-SCAN iv. C LOOK
• Disk Management
• RAID
• File access methods
• Directory structure
• File sharing and protection
Books :
1. Silberschatz, Galvin and Gagne, “Operating Systems Concepts”, Wiley
2. SibsankarHalder and Alex A Aravind, “Operating Systems”, Pearson Education
3. Harvey M Dietel, “ An Introduction to Operating System”, Pearson Education
4. D M Dhamdhere, “Operating Systems : A Concept basedApproach”, McGraw Hill.
5. Charles Crowley, “Operating Systems: A Design-Oriented Approach”, Tata McGraw Hill
Education”.
6. Stuart E. Madnick & John J. Donovan, “ Operating Systems”, Tata McGraw
Books :
1. Silberschatz, Galvin and Gagne, “Operating Systems Concepts”, Wiley
2. SibsankarHalder and Alex A Aravind, “Operating Systems”, Pearson Education
3. Harvey M Dietel, “ An Introduction to Operating System”, Pearson Education
4. D M Dhamdhere, “Operating Systems : A Concept basedApproach”, McGraw Hill.
5. Charles Crowley, “Operating Systems: A Design-Oriented Approach”, Tata McGraw Hill
Education”.
6. Stuart E. Madnick & John J. Donovan, “ Operating Systems”, Tata McGraw