You are on page 1of 26
Disks are the mainly used mass storage devices. They provide the bulk of secondary storage in operating systems today. Disk Structure Each modern disk contains concentric tracks and each track is divided into multiple sectors. The disks are usually arranged as a one dimensional array of blocks, where blocks are the smallest storage unit.Blocks can also be called as sectors. For each surface of the disk, there is a read/write desk available. The same tracks on all the surfaces is known as a cylinder. Disk Scheduling There are many disk scheduling algorithms that provide the total head movement for various requests to the disk. Here are the types of disk scheduling algorithms: ieseeoluaieis BST salto alg Shortest Seek Wingless Scheduling Dye sais( iy FN Situ ean te( 4 LOOK Scheduling All these algorithms are explained using the following requests for the disk: 10,95,23,78,80 First Come First Serve Scheduling (FCFS) In first come first served scheduling, the requests are serviced in their coming order. This algorithm is fair as it allows all requests a chance but it does not provide the fastest possible service. An example of FCFS scheduling is given below: Request Queue = 10 95 23 78 80 Head starts at 50 FCFS Disk Scheduling In the above example, the requests are serviced in the order they appear i.e 10, 95, 23, 78, 80. The seek head is_ initially positioned at 50 and it starts from there. Shortest Seek Time First Scheduling The requests that are closest to the current head are served first before moving away in shortest seek time first scheduting algorithm. A problem with SSTF algorithm is that it may cause starvation for some requests. An example of Shortest Seek Time First Scheduling is given below: Request Queue=10 95 23 78 80 Head starts at 60 ° 0 2B 50 a) 95 99 SSTF Disk Scheduling in the above example, the requests are serviced in the order 23, 10, 78, 80, 95. The seek head is initially positioned at 50 and it starts from there. 23 is closest to 50 so it is services first. Then 10 is closer to 23 than 78 so it is services next. After this 78, 80 and 95 are serviced. SCAN Scheduling in this scheduling algorithm, the head moves towards one direction while servicing all the requests in that direction until it reaches the end of the disk. After that it starts moving towards the other direction. In this way, the head continuously scans back and forth across the disk. An example of SCAN scheduling is given below: Request Queue = 10 95 20 78 80 Head starts at 50 ° 10 a 50 ze 00 9599 SCAN Disk Scheduling in the above example, the requests are serviced in the order 23, 10, 78, 80, 95. The head is initially at 50 and moves towards the left while servicing requests 23 and 10. When it reaches the end of the disk, it starts moving right and services 78, 80 and 95 as they occur. LOOK Scheduling LOOK scheduling algorithm is similar to SCAN scheduling but is its practical version. tn this algorithm, the head moves towards one direction while servicing all the requests in that direction until it reaches the last request. After that it starts moving towards the other direction. An example of LOOK scheduling is given below: Request Queue = 10 95 23 78 80 Head starts at 60 ° 10 2 50 7a 20 599 LOOK Disk Scheduling lin the above example, the requests are serviced in the order 23, 10, 78, 80, 95. The head is initially at 50 and moves towards the left while servicing requests 23 and 10. When it reaches the last request on the left i.e. 10, it starts moving right and services 78, 80 and 95 as they occur. Disk Scheduling Algorithms Disk scheduling is done by operating systems to schedule I/O requests arriving for the disk. Disk scheduling is also known as I/O scheduling. Disk scheduling is important because: e Multiple I/O requests may arrive by different processes and only one I/O request can be served at a time by the disk controller. Thus other I/O requests need to wait in the waiting queue and need to be scheduled. Two or more request may be far from each other so can result in greater disk arm movement. Hard drives are one of the slowest parts of the computer system and thus need to be accessed in an efficient manner. There are many Disk Scheduling Algorithms but before discussing them let’s have a quick look at some of the important terms: ¢ Seek Time:Seek time is the time taken to locate the disk arm to a specified track where the data is to be read or write. So the disk scheduling algorithm that gives minimum average seek time is better. ¢ Rotational Latency: Rotational Latency is the time taken by the desired sector of disk to rotate into a position so that it can access the read/write heads. So the disk scheduling algorithm that gives minimum rotational latency is better. Transfer Time: Transfer time is the time to transfer the data. It depends on the rotating speed of the disk and number of bytes to be transferred. e Disk Access Time: Disk Access Time is: Disk Access Time = Seek Time + Rotational Laten Transfer Time Disk Queuing Seek Time Rotational Delay Latency Transfer Time +<—————— Disk Access Time ———————> Disk Response Time > ° Disk Response Time: Response Time is the average of time spent by a request waiting to perform its I/O operation. Average Response time is the response time of the all requests. Variance Response Time is measure of how individual request are serviced with Disk Scheduling Algorithms 1. FCFS: FCES is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are addressed in the order they arrive in the disk queue. Advantages: ¢ Every request gets a fair chance ¢ No indefinite postponement Disadvantages: ¢ Does not try to optimize seek time ¢ May not provide the best possible service 2. SSTF: In SSTF (Shortest Seek Time First), requests having shortest seek time are executed first. So, the seek time of every request is calculated in advance in the queue and then they are scheduled according to their calculated advance in the queue and then they are scheduled according to their calculated seek time. As a result, the request near the disk arm will get executed first. SSTF is certainly an improvement over FCFS as it decreases the average response time and increases the throughput of system. Advantages: + Average Response Time decreases ¢ Throughput increases Disadvantages: ¢ Overhead to calculate seek time in advance ¢ Can cause Starvation for a request if it has higher seek time as compared to incoming requests ¢ High variance of response time as SSTF favours only some requests 3. SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the requests coming in its path and after reaching the end of disk, it reverses its direction and again services the request arriving in its path. So, this algorithm works as an elevator and hence also known as elevator algorithm. As a result, the requests at the midrange are serviced more and those arriving behind the disk arm will have to wait. Advantages: ¢ High throughput « Low variance of response time « Average response time Disadvantages: ¢ Long waiting time for requests for locations just visited by disk arm 4. CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after reversing its direction. So, it may be possible that too many requests are waiting at the other end or there may be zero or few requests pending at the scanned area. These situations are avoided in CSCAN algorithm in which the disk arm instead of reversing its direction goes to the other end of the disk and starts servicing the requests from there. So, the disk arm moves in a circular fashion and this algorithm is also similar to SCAN algorithm and hence it is known as C- SCAN (Circular SCAN). Advantages: ¢ Provides more uniform wait time compared to SCAN 5. LOOK: It is similar to the SCAN disk scheduling algorithm except for the difference that the disk arm in spite of going to the end of the disk goes only to the last request to be serviced in front of the head and then reverses its direction from there only. Thus it prevents the extra delay which occurred due to unnecessary traversal to the end of the disk. 6. CLOOK: As LOOK is similar to SCAN algorithm, in similar way, CLOOK is similar to CSCAN disk scheduling algorithm. In CLOOK, the disk arm in spite of going to the end goes only to the last request to be serviced in front of the head and then from there goes to the other end’s last request. Thus, it also prevents the extra delay which occurred due to unnecessary traversal to the end of the disk. Each algorithm is unique in its own way. Overall Performance depends on the number and type of requests. Note:Average Rotational latency is generally taken as 1/2(Rotational latency). Exercise Disk Management The operating system is responsible for several aspects of disk management. Disk Formatting Anew magnetic disk is a blank slate. It is just platters of a magnetic recording material. Before a disk can store data, it must be divided into sectors that the disk controller can read and write. This process is called low-level formatting (or physical formatting). Low-level formatting fills the disk with a special data structure for each sector. The data structure for a sector consists of a header, a data area, and a trailer. The header and trailer contain information used by the disk controller, such as a sector number and an error-correcting cote) (ECC). (ECC). To use a disk to hold files, the operating system still needs to record its own data structures on the disk. It does so in two steps. The first step is to partition the disk into one or more groups of cylinders. The operating system can treat each partition as though it were a separate disk. For instance, one partition can hold a copy of the operating system's executable code, while another holds user files. After partitioning, the second step is logical formatting (or creation of a file system). In this step, the operating system stores the initial file- system data structures onto the disk. Boot Block When a computer is powered up or rebooted, it needs to have an initial program to run. This initial program is called the bootstrap program. It initializes all aspects of the system (i.e. from CPU registers to device controllers and the contents of main memory) and then starts the operating system. To do its job, the bootstrap program finds the operating system kernel on disk, loads that kernel into memory, and jumps to an initial address to begin the operating- system execution. For most computers, the bootstrap is stored in read-only memory (ROM). This location is convenient because ROM needs no initialization and is at a fixed location that the processor can start executing when powered up or reset. And since ROM is read-only, it cannot be infected by a computer virus. The problem is that changing this bootstrap code requires ©) changing the ROM hardware chips. For this reason, most systems store a tiny bootstrap loader program in the boot ROM, whose only job is to bring in a full bootstrap program from disk. The full bootstrap program can be changed easily: A new version is simply written onto the disk. The full bootstrap program is storedina partition (at a fixed location on the disk) is called the boot blocks. A disk that has a boot partition is called a boot disk or system disk. Bad Blocks Since disks have moving parts and small tolerances, they are prone to failure. Sometimes the failure is complete, and the disk needs to be replaced, and its contents restored from backup media to the new disk. More frequently, one or more sectors become defective. Most disks even come from the factory with bad blocks. © Depending on the disk and controller i use. these blocks are handled in a variety of Since disks have moving parts and small tolerances, they are prone to failure. Sometimes the failure is complete, and the disk needs to be replaced, and its contents restored from backup media to the new disk. More frequently, one or more sectors become defective. Most disks even come from the factory with bad blocks. Depending on the disk and controller in use, these blocks are handled in a variety of ways. The controller maintains a list of bad blocks on the disk. The list is initialized during the low-level format at the factory and is updated over the life of the disk. The controller can be told to replace each bad sector logically with one of the spare sectors. This scheme is known as sector sparing or forwarding. Swap Space in Operating System Acomputer has sufficient amount of physical memory but most of times we need more so we Swap some memory on disk. Swap space is a space on hard disk which is a substitute of physical memory. It is used as virtual memory which contains process memory image. Whenever our computer run short of physical memory it uses it’s virtual memory and stores information in memory on disk. Swap space helps the computer’s operating system in pretending that it have more RAM than it actually has. It is also called as swap file. This interchange of data between virtual memory and real memory is called as swapping and space on disk as “swap space”. Virtual memory is a combination of RAM and disk space that running processes can use. Swap space is the portion of virtual memory that is on the hard disk, used when RAM is full. Swap space can be useful to computer in various ways: * It can be used as a single contiguous memory which reduces i/o operations to read or write a file. ¢ Applications which are not used or are used less can be kept in swap file. * Having sufficient swap file helps the system keep some physical memory free all the time. ¢ The space in physical memory which has been freed due to swap space can be used by OS for some other important tasks. In operating systems such as Windows, Linux, etc systems provide a certain amount of swap space by default which can be changed by users according to their needs. If you don’t want to use virtual memory you can easily disable it all together but in case if you run out of memory then kernel will kill some of the processes in order to create a sufficient amount of space in physical memory. So it totally depends upon user whether he wants to use swap space or not. Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. Its functionality list is quite similar to that of UNIX. Li nux Components of Linux System Linux Operating System has primarily three components a Kernel - Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs. a System Library - System libraries are special functions or programs using which application programs or system utilities accesses Kernel's features. These libraries implement most of the functionalities of the operating system and do not requires kernel __module's code access rights.__ a System Utility - System Utility programs are responsible to do specialized, individual level tasks. System User User Softwares | Process Utility System Libraries Kernel Modules Kernel Mode vs User Mode Kernel component code executes in a special privileged mode called kernel mode with full access to all resources of the computer. This code represents a single Process, executes in single address space and do not require any context switch and hence is very efficient and fast. Kernel runs each processes and provides system services to processes, provides protected access to hardware to processes. Support code which is not required to run in kernel mode is in System Library. User Programs and other system programs works in User Mode which has no access to system hardware and kernel code. User programs/ utilities use System libraries to access Kernel functions to get system's low level tasks. Basic Features Following are some of the important features of Linux Operating System. 8 Portable - Portability means software can works on different types of hardware in same way. Linux kernel and application programs supports their installation on any kind of hardware platform. © Open Source - Linux source code is freely available and it is community based development project. Multiple teams work in collaboration to enhance the capability of Linux operating system and it is continuously evolving. Multi-User - Linux is a multiuser system means multiple users can access system resources like memory/ ram/ application programs at same time. Multiprogramming - Linux is a multiprogramming system means multiple applications can run at same time. Hierarchical File System - Linux provides a standard file structure in which system files/ user files are arranged. Shell - Linux provides a special interpreter program which can be used to execute commands of the operating system. It can be used to do various types of operations, call application programs. etc. Security - Linux provides user security using authentication features like password protection/ controlled access to specific files/ encryption of data.

You might also like