Open In App

Difference between page and block in operating system

Last Updated : 08 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In an operating system, a block is a variable-size storage that can either read a file or write data into a file. The page is a fixed-size memory unit that can be loaded into the processor from main memory. In this article, we will provide an overview of the page and block in the operating system and then discuss the differences by mentioning the features of both. Let’s discuss it one by one.

What is a Block in OS?

The block is the smallest unit of data storage. It is used to read a file or write data to a file. A 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.

Block in OS

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.

Advantages of Using Blocks in Storage Systems

  • 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.
  • 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

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

What is Page Overview in OS?

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.

Page in os

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.

Advantages of Using Pages in Virtual Memory Systems

  • Pages allow the operating system to manage memory more efficiently by allocating memory on demand and swapping unused pages to secondary storage.
  • Pages allow for more flexible memory allocation, as applications can request memory in smaller chunks without needing to worry about physical memory constraints.
  • 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

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

BLOCK

PAGE

A block is the smallest unit of data storage that can either read a file or write data into a file.

A page is the smallest unit of in-memory storage and is RAM equivalent.

Block is a variable-size storage unit.

Page is a fixed-size memory unit.

A block is a sequence of bits and bytes. It is made up of either one sector or even number of sectors (2,4,6,…).

A page is made up of unit blocks or groups of blocks.

A block is managed by the file system.

A page is managed by the operating system’s memory management unit.

Processing with blocks is more difficult than pages when there are multiple storage devices because every device supports a different block size.

Processing with pages is easier than block when there are multiple storage devices due to the fixed size of tthe page.

A bolck is also called a physical record.

A page is also called a virtual page or memory page.

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

  • 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.
  • 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.
  • 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.

Conclusion :

In conclusion, the page and block act as a data transfer unit between main memory and secondary storage. The operating system prefers pages more than blocks for information transfer purposes. 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.



Next Article
Article Tags :

Similar Reads