I have learned that in an operating system (Linux), the memory management unit (MMU) can translate a virtual address (VA) to a physical address (PA) via the page table data structure. It seems that page is the smallest data unit that is managed by the VM. But how about the block? Is it also the smallest data unit transfered between the disk and the system memory?
Generally speaking, the hard-disk is one of those devices called "block-devices" as opposed to "character-devices" because the unit of transferring data is in the block. Even if you want only a single character from a file, the OS and the drive will get you a block and then give you access only to what you asked for while the rest remains in a specific cache/buffer.
Note: The block size, however, can differ from one system to another.
To clear a point:
Yes, any data transferred between the hard disk and the RAM is usually sent in blocks rather than actual bytes.
Data which is stored in RAM is managed, typically, by pages yes; of course the assembly instructions only know byte addresses.
What is the difference between pages and blocks? A block is the smallest unit of data that an operating system can either write to a file or read from a file.
What exactly is a page? Pages are used by some operating systems instead of blocks. A page is basically a virtual block. And, pages have a fixed size – 4K and 2K are the most commonly used sizes. So, the two key points to remember about pages is that they are virtual blocks and they have fixed sizes.
Why pages may be used instead of blocks Pages are used because they make processing easier when there are many storage devices, because each device may support a different block size. With pages the operating system can deal with just a fixed size page, rather than try to figure out how to deal with blocks that are all different sizes. So, pages act as sort of a middleman between operating systems and hardware drivers, which translate the pages to the appropriate blocks. But, both pages and blocks are used as a unit of data storage.
http://www.programmerinterview.com/index.php/database-sql/page-versus-block/
Generally speaking, the hard-disk is one of those devices called "block-devices" as opposed to "character-devices" because the unit of transferring data is in the block. Even if you want only a single character from a file, the OS and the drive will get you a block and then give you access only to what you asked for while the rest remains in a specific cache/buffer.
Note: The block size, however, can differ from one system to another.
To clear a point:
Yes, any data transferred between the hard disk and the RAM is usually sent in blocks rather than actual bytes.
Data which is stored in RAM is managed, typically, by pages yes; of course the assembly instructions only know byte addresses.
Block size is the minimum operable unit for a file system interacting with persistent memory(storage). For example, a system with ext4 file system configured at 4KiB block size will read/write in 4KiB chunks from storage at a time. Some file system support more than one block size. dumpe2fs is a linux command to retrieve file system information. On my system, dumpe2fs -h /dev/vda2 | grep "Block size"
prints 4096 because vda2
is configured with ext4 file system with default block size.
Page is the minimum operable unit for a kernel interacting with volatile memory(ram). OS Kernel could support different page sizes. In linux this value can be retrieved using getconfig command. On my system getconf PAGESIZE
returns 4096. More info at getpagesize function documentation. (Although, block and page size are same on my system, they don't have to be.)
Cache line is the minimum operable unit for CPU to move data between main memory to CPU cache. Size of cache line varies between 16 to 256 bytes, and it stays the same across different cache levels.
© 2022 - 2024 — McMap. All rights reserved.