Open In App

Difference between page and block in operating system

Improve
Improve
Like Article
Like
Save
Share
Report

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.

Example – 
PS DOS used 65,536 block addresses ( earlier, now pages are used). The default NTFS Block size is 4096 bytes.

A formatted disk

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.

Example –
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.

Block Diagram depicting paging. Page Map Table(PMT) contains pages from page number 0 to 7

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.

In operating systems, a page is a fixed size memory unit, whereas a block is a variable size storage unit.

  1. A page is the smallest unit of data that is transferred between main memory and secondary storage (usually a hard disk) in a paging-based virtual memory system. Pages are typically 4KB or 8KB in size and are managed by the operating system’s memory management unit. Each page is mapped to a physical memory frame, and the mapping is tracked by the page table.
  2. On the other hand, a block is a contiguous group of bytes or records that is read or written to secondary storage as a unit. The size of a block can vary and is often determined by the file system or storage device. For example, a file system might use a block size of 4KB or 16KB for storing files on a hard disk.
  3. In summary, a page is a fixed-size memory unit managed by the operating system’s memory management unit, whereas a block is a variable size storage unit managed by the file system or storage device.

Advantages of using pages in virtual memory systems:

  1. Pages allow the operating system to manage memory more efficiently by allocating memory on demand and swapping unused pages to secondary storage.
  2. Pages allow for more flexible memory allocation, as applications can request memory in smaller chunks without needing to worry about physical memory constraints.
  3. Pages enable the use of virtual memory, which allows applications to access more memory than is physically available on the system.

Disadvantages of using pages in virtual memory systems:

  1. Paging can introduce additional overhead, as the operating system needs to manage the mapping between virtual and physical memory.
  2. Paging can lead to decreased performance if the system is thrashing, where the operating system is constantly swapping pages in and out of memory.

Advantages of using blocks in storage systems:

  1. Blocks allow for more efficient use of storage space, as files can be stored in smaller, contiguous units rather than being fragmented across multiple sectors.
  2. Blocks can improve performance by allowing the storage device to read or write multiple blocks at once, reducing the number of disk seeks required.

Disadvantages of using blocks in storage systems:

  1. Using fixed block sizes can result in wasted storage space if a file is smaller than the block size.
  2. Using variable block sizes can introduce additional overhead, as the file system needs to keep track of the size and location of each block.

Conclusion :
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.


Last Updated : 09 Jul, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads