:PROPERTIES:
:ID: 83562885-8b11-40c2-9b18-951bd03bb863
:mtime: 20240523071017 20240308081616
:ctime: 20240308081614
:END:
#+title: paging
#+filetags: :public:operatingsystems:project:
* About Paging
- Paging is a memory-management scheme that permits the physical address space of a process to be noncontiguous.
- Paging avoids [[id:11870137-a897-451d-9dca-c67c9d2c6729][external fragmentation]] and the need for [[id:c8289a80-75be-402c-844c-89122dd2d912][compaction]].
- It also solves the considerable problem of fitting memory chunks of varying sizes onto the backing store
- paging is used in most operating systems.
- support for paging is handled by hardware.
* How is Paging Implemented?
- The basic method for implementing paging involves breaking physical memory into fixed-sized blocks called [[id:f4c06160-2fba-4dce-b76f-14519c8817ea][frames]] and breaking logical memory into blocks of the same size called [[id:fe36fb78-e621-4e47-aacc-ee06c740b64c][pages]].
- When a process is to be executed, its pages are loaded into any available memory frames from their source
- Every address generated by the CPU is divided into two parts: a page number (p) and a page offset (d).
- The page number is used as an index into a page table. The page table contains the base address of each page in physical memory. This base address is combined with the page offset to define the physical memory address that is sent to the memory unit.
** Page Size
- The page size (like the frame size) is defined by the hardware.
- The size of a page is typically a power of 2, varying between 512 bytes and 16 MB per page, depending on the computer architecture.