The document discusses memory management techniques in operating systems. It describes the buddy system for allocating memory blocks and paging for virtual memory management. Paging divides physical memory into fixed size frames and logical memory into pages. The operating system maintains a page table for each process that maps logical to physical addresses. While paging reduces internal fragmentation, it introduces overhead due to additional page table entries.
The document discusses memory management techniques in operating systems. It describes the buddy system for allocating memory blocks and paging for virtual memory management. Paging divides physical memory into fixed size frames and logical memory into pages. The operating system maintains a page table for each process that maps logical to physical addresses. While paging reduces internal fragmentation, it introduces overhead due to additional page table entries.
The document discusses memory management techniques in operating systems. It describes the buddy system for allocating memory blocks and paging for virtual memory management. Paging divides physical memory into fixed size frames and logical memory into pages. The operating system maintains a page table for each process that maps logical to physical addresses. While paging reduces internal fragmentation, it introduces overhead due to additional page table entries.
Buddy System • Entire space available is treated as a single block of 2U • If a request of size s such that 2U-1 < s <= 2U, entire block is allocated – Otherwise block is split into two equal buddies – Process continues until smallest block greater than or equal to s is generated
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 2
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 3 Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 4 Paging • Divide physical memory into fixed-sized blocks [frames] – Size is power of 2 • Divide logical memory into blocks of same size [pages] • Keep track of all free frames • To run a process of size N pages, need to find N free frames [Max] • Set up a page table to translate logical to physical addresses • Backing storage split into pages • Internal fragmentation Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 5 Paging • Operating system maintains a page table for each process – Contains the frame location for each page in the process – Memory address consist of a page number and offset within the page • Page number (p) – used as an index into a page table which contains base address of each page in physical memory • Page offset (d) – combined with base address to define the physical memory address that is sent to the memory unit
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 6
Address Translation Scheme page number page offset p d m-n n • For given logical address space 2m and page size 2n • Size of a page is typically a power of 2, varying between 512bytes & 16MB per page – The selection of a power of 2 as page size makes the translation of logical address into a page number and page offset easy
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 7
Paging Hardware
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 8
Paging Model of Logical & Physical Memory
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 9
Paging – Calculating internal fragmentation • Page size = 2,048 bytes • Process size = 72,766 bytes [35 pages + 1,086 bytes] • Internal fragmentation of 2,048 - 1,086 = 962 bytes • Worst case fragmentation = 1 frame – 1 byte • On average fragmentation = 1 / 2 frame size • So small frame sizes desirable? • But each page table entry takes memory to track • Page sizes growing over time – Solaris supports two page sizes – 8 KB and 4 MB – Intel supports two page sizes – 4KB and 4MB Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 10 Free Frames
Before allocation After allocation
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 11 Assignment of Process Pages to free frames
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 12
Assignment of Process Pages to free frames
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 13
Page Tables - Example
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 14
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 15 • Internal fragmentation results • To reduce internal fragmentation we need to reduce the page size. – there will be an overhead of page table entry. • Page sizes now in use are typically between 4KB and 8KB. • Some CPU and kernel supports multiple page sizes. Example : Solaris 8KB and 4MB pages • Main advantage of paging is the separation of user view of memory & actual physical memory. • User process cannot access memory outside of its page table.
Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 16
• Disadvantage: Paging – Internal fragmentation • Reduce the page size to reduce fragmentation – Overhead because of increase in More page table entries • Advantage: – Separation of user view of memory & actual physical memory – User process cannot access memory outside of its page table Thursday, November 23, 2023 Biju K Raveendran @ BITS Pilani Goa 17