File Management in Operating System Tutorial Study Notes with Examples
Logically related data items on the secondary storage are usually organized into named collections called files. A file may contain a report an executed program as a set of commands to the operating system. A file often appears to the users as a linear array of characters or record structures.
The file system consists of two parts
(i) A collection of files (ii) A directory structure
The file management system can be implemented as one or more layers of the operating system.
The common responsibilities of the file management system includes the following
- Mapping of access requests from logical to physical file address space.
- Transmission of file elements between main and secondary storage.
- Management of the secondary storage such as keeping track of the status allocation and deallocation of space.
- Support for protection and sharing of files and the recovery and possible restoration of the files after system crashes.
Each file is referred to by its name. The file is named for the convenience of the users and when a file is named, it becomes independent of the user and the process. Below are file attributes
- Time and date
One the responsibilities of the OS is to use the hardware efficiently. For the disk drives, meeting this responsibility entails having fast access time and l large disk bandwidth.
Access time has two major components
- Seek time is the time for the disk arm to move the heads to the cylinder containing the desired sector.
- The rotational latency is the additional time for the disk to rotate the desired sector to the disk head. It is not fixed, so we can take average
Rotational latency = One complete revolution time
Disk bandwidth is the total number of bytes transferred, divided by the total time between the first for service and the completion of last transfer.
The OS provides system call to create, read , write, delete and truncate files.
The common file operations are as follows
- File Creation: For a file to be created firstly, a space must be found for a file, in the be file system and secondarily a new entry must be made in the directory for the new
- Writing a File: In order to write a file, a system call is made, which specify the file name and the information to be written in file.
- Reading a File: To read from a file, we use a system call that specifies the name of the file and where in the memory. The next block of the file should be put and again for the associated directory entry.
- Re-positioning within a File: Re positioning within a file doesn’t need to invoke any actual I/O. This is also known as file seek.
- File Deletion: The directory for the named file is searched in order to delete a file and when the associated directory entry is found, all the file space is released and the directory entry is removed.
- Truncating a File: Truncating a file is used when the user wants the attributes of the file to remain the same but wants to erase the contents of the file. There is no use of deleting a file and recreating it rather this function allow all attributes to remain unchanged but for the file to reset the length zero.
This is also known as First In First Out (FIFO) simply queue processes the order that they arrive in the ready queue.
The following features which FIFO scheduling have.
- First come first served scheduling.
- Processes request sequentially.
- Fair to all processes, but it generally does not provide the faster service .
- Consider a disk queue with requests for I/O to blocks on cylinder . e
Queue = 98,183, 37, 122, 14, 124 , 65, 67
The wild swing from 122 to 14 and then back to 124 illustrates the problem with this schedule. If the requests for cylinder 37 and 14 could be serviced together, before or after the requests for 122 and 124, the total head movement could be decreased substantially and performance could be there by improved.
Shortest Seek Time First (SSTF) Scheduling
It selects the request with the minimum seek time from the current head position. SSTF scheduling is a form of SJF scheduling may cause
starvation of some requests. It is not an optimal algorithm but its improvement over FCFS.
Queue = 98, 183, 37, 122, 14, 124, 65, 67 Head starts at 53.
- This scheduling method results in a total head movement of only 236 cylinders little more than one-third of the distance needed for FOFS scheduling of this request time. Clearly this algorithm gives a substantial improvement in performance.
In the SCAN algorithm, the disk arm starts at one end of the disk rail moves toward the other end, servicing requests as it reaches each cylinder, until it gets to the other end of the disk. At the other end, the direction of head movement is reversed and servicing continues. The head continuously scans back and forth across the disk. The SCAN algorithm is sometimes called the elevator algorithm, since the disk arm behaves just like an elevator in a building, first servicing all the request going up and then reversing to service requests the other way.
Queue = 98, 183, 37, 122, 14, 124, 65, 67 Head starts at 53.
Circular SCAN is a variant of SCAN, which is designed to provide a more uniform wait time. Like SCAN, C-SCAN moves the head from one end ol the disk to the other, servicing requests along the way. When the head, reaches the other end, however it immediately returns to the beginning, of the disk without servicing any requests on the return trip. The C–-SCAN scheduling algorithm essentially treats the cylinders as a circular list that wraps around from the final cylinder to the first one.
Queue = 98, 183, 37, 122, 14, 124, 65, 67
Head starts at 53.
C-SCAN disk scheduling
- Bootstrap For a computer to start running for instances when it is powered up or rebooted, it needs to have an initial program to run. This initial program is known as bootstrap program.
- Bootstrap program is stored in ROM or EEPROM which is known as a firmware.
- System Calls System calls provide an interface to the service made available by operating system.
- Single Processor System In a single processor system, there is one main CPU capable of executing a general purpose instruction set, including instructions from user processes.
- Multi Processor System It is alos known as a parallel system or tightly coupled system.
- Cluster System In Cluster system, computers share common storage and are closely linked via a LAN.
Different Types of Scheduling Algorithm
|Scheduling Algorithm||CPU Overhead||Throughput||Turn Around Time I||Response
|First In First Out||Low||Low||High||Low|
|Shortest job first||Medium||High||Medium||Medium|
Sorting in Design and Analysis of Algorithm Study Notes with Example
Learn Sorting in Handbook Series: Click here