Difference between page and block in operating system
In this article, we will discuss the overview of the page and block in Operating System and then will discuss the differences by mentioning features of both. Let’s discuss it one by one.
Block Overview :
Block is the smallest unit of data storage. It is used to read a file or write data to a file. Block is also a sequence of bits and bytes. Block is made up of sectors. A sector is a physical spot on a formatted disk that holds information. A block is made up of either one sector or even no of sectors (2,4,6..). A block is also called a physical record.
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
PS DOS used 65,536 block addresses ( earlier, now pages are used). The default NTFS Block size is 4096 bytes.
Features of Block :
- Most of the OS use blocks for storing data.
- When we put the data into the block it is known as blocking and when we extract data from blocks it is known as deblocking.
- Blocks can be of different sizes. The size of the block is known as the block size.
- Every file in OS occupies at least one block even if it is of 0 bytes.
- Block provides a level of abstraction for hardware that is responsible for storing and retrieving the data.
- Blocking increases the data handling streams speed and reduces overhead.
Page Overview :
A page is also a unit of data storage. A page is loaded into the processor from the main memory. A page is made up of unit blocks or groups of blocks. Pages have fixed sizes, usually 2k or 4k. A page is also called a virtual page or memory page. When the transfer of pages occurs between main memory and secondary memory it is known as paging. Refer to https://www.geeksforgeeks.org/paging-in-operating-system/ for a detailed explanation.
A well-known example depicting the usage of pages is Storage Area Network. Storage Area Network(SAN) uses paging to move data between driver types.
Features of Page :
- The size of pages is determined by processor architecture.
- Some of the OS use pages instead of blocks.
- Pages are the smallest unit of in-memory storage and are RAM equivalent.
- If the page required by the processor is not present in the main memory, it is known as a page fault and it is brought in the main memory by a special routine known as page fault routine.
- The technique of getting the desired page in the main memory is known as page demanding.
- Pages act as a middleman between OS and hard drives.
Pages are preferred more than blocks by OS. The very first reason is that processing with pages is easier than the block when there are multiple storage devices. Also, the page size is usually fixed and blocks have varied sizes. However, both page and block are data storage units.