Unit V - Disk Management and Case Study - Unix Systems
Unit V - Disk Management and Case Study - Unix Systems
Unit V
Disk Management, and
Case Study – Unix File System
• Magnetic disk is a storage device that is used to write, rewrite and access data.
• The entire disk is divided into platters.
• Each platter consists of concentric circles called as tracks.
• These tracks are further divided into sectors which are the smallest divisions in the disk.
• The time taken by the disk to complete an I/O request is called as disk service time or disk access
time.
• Components that contribute to the service time are-
• Seek time
• Rotational latency
• Data transfer rate
• Controller overhead
• Queuing delay
• Seek Time:
• The time taken by the read / write head to reach the desired track is called as seek time.
• It is the component which contributes the largest percentage of the disk service time.
• The lower the seek time, the faster the I/O operation.
. Rotational Latency
• The time taken by the desired sector to come under the read / write head is called as rotational
latency.
• It depends on the rotation speed of the spindle.
• Controller Overhead:
• The overhead imposed by the disk controller is called as controller overhead.
• Disk controller is a device that manages the disk.
• Queuing Delay:
• The time spent waiting for the disk to become free is called as queuing delay.
• Storage Density-
• All the tracks of a disk have the same storage capacity.
• This is because each track has different storage density.
• Storage density decreases as we move from one track to another track away from the center.
• Thus,
Innermost track has maximum storage density.
Outermost track has minimum storage density.
• Disk scheduling is a technique used by the operating system to schedule multiple requests for
accessing the disk.
• The algorithms used for disk scheduling are called as disk scheduling algorithms.
• The purpose of disk scheduling algorithms is to reduce the total seek time.
• FCFS Algorithm
• SSTF Algorithm
• SCAN Algorithm
• C-SCAN Algorithm
• LOOK Algorithm
• C-LOOK Algorithm
• It is the simplest disk scheduling algorithm, it entertains requests in order they arrive in the disk queue.
• It results in increased total seek time and it is inefficient.
• We illustrate scheduling algorithms with a request queue (0-199)
= (98 – 53) + (183 – 98) + (183 – 41) + (122 – 41) + (122 – 14) + (124 – 14) + (124 – 65) + (67 – 65)
= 632
• Consider a disk system with 100 cylinders. The requests to access the cylinders occur in following
sequence-
4, 34, 10, 7, 19, 73, 2, 15, 6, 20
• Assuming that the head is currently at cylinder 50, what is the time taken to satisfy all requests if it
takes 1 ms to move from one cylinder to adjacent one and shortest seek time first policy is used?
• 95 ms
• 119 ms
• 233 ms
• 276 ms
• As the name suggests, this algorithm scans all the cylinders of the disk back and forth.
• Head starts from one end of the disk and move towards the other end servicing all the requests in
between.
• After reaching the other end, head reverses its direction and move towards the starting end servicing
all the requests in between.
• The same process repeats.
•
SCAN Algorithm is also called as Elevator Algorithm.
• This is because its working resembles the working of an elevator.
Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67.
The SCAN scheduling algorithm is used. The head is initially at cylinder number 53 moving towards
larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. The total
head movement (in number of cylinders) incurred while servicing these requests is _______.
Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67.
The SCAN scheduling algorithm is used. The head is initially at cylinder number 53 moving towards
larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. The total
head movement (in number of cylinders) incurred while servicing these requests is _______.
Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67.
The SCAN scheduling algorithm is used. The head is initially at cylinder number 53 moving towards
larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. The total
head movement (in number of cylinders) incurred while servicing these requests is _______.
Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67.
The SCAN scheduling algorithm is used. The head is initially at cylinder number 53 moving towards
larger cylinder numbers on its servicing pass. The cylinders are numbered from 0 to 199. The total
head movement (in number of cylinders) incurred while servicing these requests is _______.
• When the computer is turned on or restarted, the program stored in the initial
bootstrap ROM finds the location of the OS kernel from the disk, loads the
kernel into memory, and runs the OS. start.
• To change the bootstrap code, you need to change the ROM and hardware chip.
Only a small bootstrap loader program is stored in ROM instead.
• The full bootstrap code is stored in the “boot block” of the disk.
• Most disks are even stuffed from the factory with bad blocks and are handled
in a variety of ways.
• The controller can instruct each bad sector to be logically replaced with one of
the spare sectors. This scheme is known as sector sparing or transfer.
• Most disks are even stuffed from the factory with bad blocks and are handled
in a variety of ways.
• The controller can instruct each bad sector to be logically replaced with one of
the spare sectors. This scheme is known as sector sparing or transfer.
• Partitioning: This involves dividing a single physical disk into multiple logical partitions. Each
partition can be treated as a separate storage device, allowing for better organization and management
of data.
• Formatting: This involves preparing a disk for use by creating a file system on it. This process typically
erases all existing data on the disk.
• File system management: This involves managing the file systems used by the operating system to
store and access data on the disk. Different file systems have different features and performance
characteristics.
• Disk space allocation: This involves allocating space on the disk for storing files and directories. Some
common methods of allocation include contiguous allocation, linked allocation, and indexed allocation.
• Disk defragmentation: Over time, as files are created and deleted, the data on a disk can become
fragmented, meaning that it is scattered across the disk. Disk defragmentation involves rearranging the
data on the disk to improve performance.
07-05-2025 ©Operating Systems @ Srilakshmi V 33
Unix OS
UNIX is a powerful Operating System initially developed by Ken Thompson, Dennis Ritchie at
AT&T Bell laboratories in 1970. It is prevalent among scientific, engineering, and academic
institutions due to its most appreciative features like multitasking, flexibility, and many more.
In UNIX, the file system is a hierarchical structure of files and directories where users can
store and retrieve information using the files.
Multitasking: A UNIX operating system is a multitasking operating system that allows you to
initiate more than one task from the same terminal so that one task is performed as a
foreground and the other task as a background process.
Multi-user: UNIX operating system supports more than one user to access computer resources
like main memory, hard disk, tape drives, etc. Multiple users can log on to the system from
different terminals and run different jobs that share the resources of a command terminal. It
deals with the principle of time-sharing. Time-sharing is done by a scheduler that divides the
CPU time into several segments also called a time slice, and each segment is assigned to
each user on a scheduled basis. This time slice is tiny. When this time is expired, it passes
control to the following user on the system. Each user executes their set of instructions
within their time slice.
07-05-2025 ©Operating Systems @ Srilakshmi V 34
Features of Unix OS
Portability: This feature makes the UNIX work on different machines and platforms with the easy transfer of code to any computer
system. Since a significant portion of UNIX is written in C language, and only a tiny portion is coded in assembly language for
specific hardware.
File Security and Protection: Being a multi-user system, UNIX makes special consideration for file and system security. UNIX has
different levels of security using assigning username and password to individual users ensuring the authentication, at the level
providing file access permission viz. read, write and execute and lastly file encryption to change the file into an unreadable format.
Command Structure: UNIX commands are easy to understand and simple to use. Example: "cp", mv etc. While working in the UNIX
environment, the UNIX commands are case-sensitive and are entered in lower case.
Communication: In UNIX, communication is an excellent feature that enables the user to communicate worldwide. It supports
various communication facilities provided using the write command, mail command, talk command, etc.
Open Source: UNIX operating system is open source it means it is freely available to all and is a community-based development
project.
Accounting: UNIX keeps an account of jobs created by the user. This feature enhances the system performance in terms of CPU
monitoring and disk space checking. It allows you to keep an account of disk space used by each user, and the disk space can be
limited by each other.
07-05-2025 ©Operating Systems @ Srilakshmi V 35
Structure of Unix OS
Layer-2: Kernel -
The core of the operating system that's liable for maintaining the full functionality is
named the kernel. The kernel of UNIX runs on the particular machine hardware and
• The kernel also manages the memory. Processes are executed programs that have
owner's humans or systems who initiate their execution.
• The system must provide all processes with access to an adequate amount of
memory, and a few processes require a lot of it. To make effective use of main
memory and to allocate a sufficient amount of memory to every process. It uses
essential techniques like paging, swapping, and virtual storage.
• If you need to repeat a command you typed it, use the cursor keys to scroll up and
down the list or type history for a list of previous commands. There are various
commands like cat, mv, cat, grep, id, wc, and many more
• Bourne Shell: This Shell is simply called the Shell. It was the first Shell for
UNIX OS. It is still the most widely available Shell on a UNIX system.
• C Shell: The C shell is another popular shell commonly available on a UNIX system.
The C shell was developed by the University of California at Berkeley and removed
some of the shortcomings of the Bourne shell.
• Korn Shell: This Shell was created by David Korn to address the Bourne Shell's
user-interaction issues and to deal with the shortcomings of the C shell's scripting
quirks.
head -n 5 largefile.txt
tail -f /var/log/syslog
The first line of a shell script typically starts with a shebang (#!) followed by the path
to the interpreter, which tells the system which shell to use to execute the script.
sh
#!/bin/bas
2. Comments
Comments in shell scripts start with a # and extend to the end of the line.
sh
# This is a comment
sh
name="John"
While Loop
sh count=1
while [ $count -le 5 ];
do echo "Count: $count"
count=$((count + 1))
done
Functions
Functions allow you to encapsulate a block of code that you can reuse throughout your
script.
sh greet()
{
echo "Hello, $1"
}
greet "Alice”
Standard Input (stdin): Typically the keyboard, accessed via file descriptor 0.
Standard Output (stdout): Usually the terminal, accessed via file descriptor 1.
Standard Error (stderr): For error messages, accessed via file descriptor 2.
Example:
# Output to stderr
echo "This is an error message" >&2
# Redirecting input and output
echo "Writing to file" > output.txt <cat output.txt
# Piping commands
ls | grep ".txt“