Operating system Notes

mobiprep (6).png

Introduction of Operating System

mobiprep (6).png

PROCESS: Program to process, Lifecycle of the process, Process control block, IPC

mobiprep (6).png

Scheduling

mobiprep (6).png

Threads

mobiprep (6).png

Memory Management

mobiprep (6).png

File Management

mobiprep (6).png

Synchronization

mobiprep (6).png

Disk Management

mobiprep (6).png

IO Management

mobiprep (6).png

Protection And Security

Heading

Q

1

What are the poperties of a Hard magnetic disk?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The following are the properties of a magnetic hard disk:
1.A magnetic hard disk uses magnetization to read and write data.
2.The information is stored in the form of a magnetic field below the surface of the spinning disk.
3.Each disk platter is covered with a magnetic material, so that the data can be written in the form of a magnetic field on its surface.
4.The magnetic hard disks are non-volatile. Hence, they are used for permanent storage of data.
5.Many circular disks are stacked on top of one another to form the magnetic hard disk. Each circular disk can store 10MB to 10GB of data.

LRM_EXPORT_207556595493866_20190724_1939

Q

2

What is Rotation latency and transfer time?

LRM_EXPORT_207556595493866_20190724_1939

Ans

Rotation Latency
The rotation latency is the time taken by the read/write head to seek the requested sector in the disk from the current location.
EXAMPLE:
Consider that the read/write head is currently in sector 2. If the required data is in sector 5, then the read/write head has to be moved to sector 5 to read the data. The time taken for the read/write head to reach sector 5 from sector 2 is called rotational latency.
Transfer Time
Transfer time is the time taken to transfer the data from the disk to the main memory. The data transfer time depends on the rotational speed of the disks in the secondary memory.
Transfer time = data to be transferred/data transfer rate
Transfer rate refers to the amount of data transferred per unit time.

LRM_EXPORT_207556595493866_20190724_1939

Q

3

Give a description on disc structure?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The magnetic hard disk usually contains circular disks stacked on top of one another. A hard disk contains approximately 100 to 200 disks. These circular disks are called platters. The platters are mounted on a spindle. The spindle holds the disk in position and helps the disks to rotate. As the disks are stacked on top of one another, the hard disk looks like a cylinder.
Each platter is divided into many concentric rings called tracks. The tracks are further divided into sectors. Traditionally, a sector contains 512 bytes of storage. Though the outer tracks are larger in size than the inner tracks, both the inner and the outer tracks have the same number of sectors. But, the sectors in the inner tracks are denser than the sectors in the outer tracks.
The read/write head is used to read the data from a particular sector of the disk. Each disk platter has a separate read/write head. These read/write heads are controlled by the arm assembly. To read or write data into the disk, the read/write arm is positioned over that specific sector.

LRM_EXPORT_207556595493866_20190724_1939

Q

4

What is bit map?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The mapping of integers to bits is called a bit map. In a bitmap, the secondary memory is divided into blocks. Each block is associated with a bit in the bitmap. The bitmap is used to keep track of secondary memory easily. The bitmap depends on the size of the memory.
If a block is occupied, its corresponding bit value is 1. If the block is empty, the corresponding bit value is 0.

LRM_EXPORT_207556595493866_20190724_1939

Q

5

What are various alocation methods in a disc?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The following are the three major disk allocation methods:
Contiguous allocation
Linked allocation
Indexed allocation
Contiguous allocation
In contiguous allocation, the files occupy contiguous memory locations in the disk. For contiguous allocation, the starting address and the length of the file are required. Using these two data, the blocks which are occupied by the file can be found out. It is a simple and fast method of disk allocation.
Contiguous allocation results in both internal and external fragmentation. It leads to wastage of memory. It is inefficient in terms of memory usage.

Linked allocation
In linked allocation, the file need not be allocated contiguous locations in the memory. Instead, the pointer to the next memory location occupied by the file is used. Each block contains a pointer to the next memory location.
Linked allocation does not cause external fragmentation. The memory is used efficiently. But, extra memory is used for storing the pointers.

Indexed allocation
In indexed allocation, each file has an index. The index consists of pointers to the memory locations occupied by the file. Indexed allocation can be clearly understood from the diagram given below:

LRM_EXPORT_207556595493866_20190724_1939

Q

6

Explain Disc Scheduling?

LRM_EXPORT_207556595493866_20190724_1939

Ans

The I/O requests are used to access the disk. If multiple I/O requests occur at the same time seeking disk access, the operating system schedules the request in such a way that the disk utilization is efficient. Different scheduling algorithms are used to schedule the I/O requests. These algorithms are explained below.
FCFS
FCFS – First Come First Served
The requests are served based on their arrival time.
The request which arrives first is served first
It is the simplest disk scheduling algorithm.
SSTF
SSTF – Shortest Seek Time First
The request with the shortest seek time is served first.
If the request is nearer to the current position of the disk arm, it is processed first.
It increases the throughput of the system.
SCAN
It is also called the elevator algorithm.
Here, the disk arm moves in a specific direction till it reaches the end of the disk. The requests are served on its path.
After reaching the end of the disk, the direction of the arm is reversed, and the requests are served on the path.
C-SCAN
The disk arm moves towards the end of the disk.
After reaching the end of the disk, it reverses its direction. Now, the arm services the request on its way.
LOOK
It is similar to SCAN. But, instead of going to the end of the disk, it goes to the last request to be serviced. Then, it reverses its direction.
The requests are serviced on the way.
C-LOOK
It is similar to C-SCAN. But, instead of going to the end of the disk, it goes to the last request to be serviced.
The requests are serviced only after the reversal of direction of the arm.
EXAMPLE
Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67. The head is initially at cylinder number 53. The cylinders are numbered from 0 to 199.
FCFS
Total head movements incurred while servicing these requests
= (98 – 53) + (183 – 98) + (183 – 41) + (122 – 41) + (122 – 14) + (124 – 14) + (124 – 65) + (67 – 65)
= 45 + 85 + 142 + 81 + 108 + 110 + 59 + 2
= 632

SSTF
Total head movements incurred while servicing these requests

= (65 – 53) + (67 – 65) + (67 – 41) + (41 – 14) + (98 – 14) + (122 – 98) + (124 – 122) + (183 – 124)
= 12 + 2 + 26 + 27 + 84 + 24 + 2 + 59
= 236

SCAN
Total head movements incurred while servicing these requests
= (199 – 53) + (199 – 14)
= 146 + 185
= 331

C-SCAN
Total head movements incurred while servicing these requests

= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) + (199 – 0) + (14 – 0) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 27
= 386

LOOK
Total head movements incurred while servicing these requests

= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 41) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 142 + 27
= 299

C-LOOK
Total head movements incurred while servicing these requests

= (183 – 53) + (183 – 14) + (41 – 14)
= 130 + 169 + 27
= 326

LRM_EXPORT_207556595493866_20190724_1939

Q

7

What is SCAN, C-SCAN, C-LOOK?

LRM_EXPORT_207556595493866_20190724_1939

Ans

SCAN, C-SCAN and C-LOOK are the disk scheduling algorithms.
SCAN
It is also called the elevator algorithm.
Here, the disk arm moves in a specific direction till it reaches the end of the disk. The requests are served on its path.
After reaching the end of the disk, the direction of the arm is reversed, and the requests are served on the path.
C-SCAN
The disk arm moves towards the end of the disk.
After reaching the end of the disk, it reverses its direction. Now, the arm services the request on its way.

C-LOOK
It is similar to C-SCAN. But, instead of going to the end of the disk, it goes to the last request to be serviced.
The requests are serviced only after the reversal of direction of the arm.
EXAMPLE
Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124, 65, 67. The head is initially at cylinder number 53. The cylinders are numbered from 0 to 199.

SCAN
Total head movements incurred while servicing these requests
= (199 – 53) + (199 – 14)
= 146 + 185
= 331

C-SCAN
Total head movements incurred while servicing these requests

= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) + (199 – 0) + (14 – 0) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 27
= 386

C-LOOK
Total head movements incurred while servicing these requests

= (183 – 53) + (183 – 14) + (41 – 14)
= 130 + 169 + 27
= 326

LRM_EXPORT_207556595493866_20190724_1939

Q

8

Define seek time and latency time.

LRM_EXPORT_207556595493866_20190724_1939

Ans

Seek Time
Seek time is the time taken by the disk arm to seek the required track in the disk.
Latency Time
Latency time is the time taken by the disk arm to seek the beginning of the required sector in a track. Latency time is also called rotational delay.
Memory access time = seek time + latency time

LRM_EXPORT_207556595493866_20190724_1939

Q

9

Write notes about disk management and swap-space management.

LRM_EXPORT_207556595493866_20190724_1939

Ans

Disk management
Disk management is a utility in every operating system to manage the hard disk drives. Disk management involves creation and deletion of partitions, assignment of drive letters etc., it also involves viewing the partitions in the disk. It is also used to format the partitions and file systems in the hard disk.
Swap-space management
Swap space is the part of the hard disk where the processes which are swapped out of the main memory are stored.
Swap-space management involves the efficient usage of the swap-space to improve the throughput of the system. The swap-space required must be overestimated to prevent crashing of processes due to insufficient swap-space. The swap space must be located either in the normal file system or in a separate disk partition. The swap-space location and the swap-space size are decided by the operating system.

LRM_EXPORT_207556595493866_20190724_1939

Q

10

What is RAID? Explain its various levels

LRM_EXPORT_207556595493866_20190724_1939

Ans

RAID – Redundant Array of Independent Disks
RAID is a technique which introduces data redundancy in the disk to improve its performance and reliability. Though this technique requires additional storage space, it greatly increases the reliability of disk data. This technique is used to prevent the loss of data in case of disk failure.
RAID 0 (Striping)
In RAID 0, the data is not duplicated. The blocks are striped across the disks. Hence, data once lost cannot be recovered. It is intolerant to disk failure.

RAID 1 (Mirroring)
Every block has multiple copies in different disks. The copies of the blocks are stored in different disks. RAID 1 is reliable and tolerant to disk failure.
Assume that there exists 2 copies of a block (level 2 mirroring).It can tolerate maximum of N/2 disk failures.

RAID 4 (Block-Level Striping with Dedicated Parity)
In RAID 4 data is not duplicated. Instead, parity bits are used. All the parity bits are stored in the same disk. The parity bit is calculated by XORing all the input bits. If the number of 1’s in the input is odd, the parity bit is 1. Else, the parity bit is 0.
This technique can detect at most one disk failure. If more than one disks fail, this method cannot be used to recover the data.

RAID 5 (Block-Level Striping with Distributed Parity)
It is similar to RAID 4, but the parity bits are distributed among the disks. This is clearly shown in the figure. Using this technique, atmost one disk failure can be detected. But, the performance of RAID 5 is better than RAID 4.

LRM_EXPORT_207556595493866_20190724_1939