Segmented Paging
Segmented Paging
Segmented Paging
Pure segmentation is not very popular and not being used in many of the
operating systems. However, Segmentation can be combined with Paging to
get the best features out of both the techniques.
Each Page table contains the various information about every page of the
segment. The Segment Table contains the information about every segment.
Each segment table entry points to a page table entry and every page table
entry is mapped to one of the page within a segment.
Translation of logical address to physical address
The CPU generates a logical address which is divided into two parts:
Segment Number and Segment Offset. The Segment Offset must be less
than the segment limit. Offset is further divided into Page number and Page
Offset. To map the exact page number in the page table, the page number is
added into the page table base.
The actual frame number with the page offset is mapped to the main
memory to get the desired word in the page of the certain segment of the
process.
Advantages of Segmented Paging
1. It reduces memory usage.
2. Page table size is limited by the segment size.
3. Segment table has only one entry corresponding to one actual segment.
4. External Fragmentation is not there.
5. It simplifies memory allocation.
System files and data are kept in the computer system's memory, and when these files are needed
by an application, the operating system must have some way to read the memory and access the
appropriate files. There are three file access methods in OS, sequential access, direct access, and
indexed sequential access.
A file is a collection of bits/bytes or lines that is stored on secondary storage devices like a hard
drive (magnetic disks).
File access methods in OS are nothing but techniques to read data from the system's memory.
There are various ways in which we can access the files from the memory like:
Sequential Access
Direct/Relative Access, and
Indexed Sequential Access.
These methods by which the records in a file can be accessed are referred to as the file access
mechanism. Each file access mechanism has its own set of benefits and drawbacks, which are
discussed further in this article.
The operating system reads the file word by word in a sequential access method of file accessing.
A pointer is made, which first links to the file's base address. If the user wishes to read the first
word of the file, the pointer gives it to them and raises its value to the next word. This procedure
continues till the file is finished. It is the most basic way of file access. The data in the file is
evaluated in the order that it appears in the file and that is why it is easy and simple to access a
file's data using a sequential access mechanism. For example, editors and compilers frequently
use this method to check the validity of the code.
Sequential access will become slow if the next file record to be retrieved is not present next to
the currently pointed record.
Adding a new record may need relocating a significant number of records of the file.
2. Direct (or Relative) Access
A Direct/Relative file access mechanism is mostly required with the database systems. In the
majority of the circumstances, we require filtered/specific data from the database, and in such
circumstances, sequential access might be highly inefficient. Assume that each block of storage
holds four records and that the record we want to access is stored in the tenth block. In such a
situation, sequential access will not be used since it will have to traverse all of the blocks to get
to the required record, while direct access will allow us to access the required record instantly.
The direct access mechanism requires the OS to perform some additional tasks but eventually
leads to much faster retrieval of records as compared to sequential access.
The files can be retrieved right away with a direct access mechanism, reducing the average
access time of a file.
There is no need to traverse all of the blocks that come before the required block to access the
record.
The direct access mechanism is typically difficult to implement due to its complexity.
Organizations can face security issues as a result of direct access as the users may access/modify
the sensitive information. As a result, additional security processes must be put in place.
3. Indexed Sequential Access
It's the other approach to accessing a file that's constructed on top of the sequential access
mechanism. This method is practically similar to the pointer-to-pointer concept in which we
store the address of a pointer variable containing the address of some other variable/record in
another pointer variable. The indexes, similar to a book's index (pointers), contain a link to
various blocks present in the memory. To locate a record in the file, we first search the indexes
and then use the pointer-to-pointer concept to navigate to the required file.
Primary index blocks contain the links of the secondary inner blocks which contain links to the
data in the memory.
If the index table is appropriately arranged, it accesses the records very quickly.
Records can be added at any position in the file quickly.
Seek Time - It is the time taken by the disk arm to locate the
desired track.
Rotational Latency - The time taken by a desired sector of the
disk to rotate itself to the position where it can access the
Read/Write heads is called Rotational Latency.
Transfer Time - It is the time taken to transfer the data
requested by the processes.
Disk Access Time - Disk Access time is the sum of the Seek
Time, Rotational Latency, and Transfer Time.
In this algorithm, the requests are served in the order they come.
Those who come first are served first. This is the simplest algorithm.
Eg. Suppose the order of requests are 70, 140, 50, 125, 30, 25, 160
and the initial position of the Read-Write head is 60.
Seek Time = Distance Moved by the disk arm = (140-70)+(140-
50)+(125-50)+(125-30)+(30-25)+(160-25)=480
In this algorithm, the shortest seek time is checked from the current
position and those requests which have the shortest seek time is
served first. In simple words, the closest request from the disk arm is
served first.
Eg. Suppose the order of requests are 70, 140, 50, 125, 30, 25, 160
and the initial position of the Read-Write head is 60.
In this algorithm, the disk arm moves in a particular direction till the
end and serves all the requests in its path, then it returns to the
opposite direction and moves till the last request is found in that
direction and serves all of them.
Eg. Suppose the order of requests are 70, 140, 50, 125, 30, 25, 160
and the initial position of the Read-Write head is 60. And it is given
that the disk arm should move towards the larger value.
LOOK
In this algorithm, the disk arm moves in a particular direction till the
last request is found in that direction and serves all of them found in
the path, and then reverses its direction and serves the requests
found in the path again up to the last request found. The only
difference between SCAN and LOOK is, it doesn't go to the end it only
moves up to which the request is found.
Eg. Suppose the order of requests are 70, 140, 50, 125, 30, 25, 160
and the initial position of the Read-Write head is 60. And it is given
that the disk arm should move towards the larger value.
Seek Time = Distance Moved by the disk arm = (170-60)+(170-
25)=235
C-SCAN
This algorithm is the same as the SCAN algorithm. The only difference
between SCAN and C-SCAN is, it moves in a particular direction till
the last and serves the requests in its path. Then, it returns in the
opposite direction till the end and doesn't serve the request while
returning. Then, again reverses the direction and serves the requests
found in the path. It moves circularly.
Eg. Suppose the order of requests are 70, 140, 50, 125, 30, 25, 160
and the initial position of the Read-Write head is 60. And it is given
that the disk arm should move towards the larger value.
This algorithm is also the same as the LOOK algorithm. The only
difference between LOOK and C-LOOK is, it moves in a particular
direction till the last request is found and serves the requests in its
path. Then, it returns in the opposite direction till the last request is
found in that direction and doesn't serve the request while returning.
Then, again reverses the direction and serves the requests found in
the path. It also moves circularly.
Eg. Suppose the order of requests are 70, 140, 50, 125, 30, 25, 160
and the initial position of the Read-Write head is 60. And it is given
that the disk arm should move towards the larger value.