Additional Benefits besides cache aspect:
libc
. This greatly reduced the memory needed for multiple processes since many processes use similar libraries.Notice malloc
is allocating large data using mmap()
, only page table entry and swap file (maybe, depending on specific malloc
implementation, malloc may try to write header or footer) is changed during the process.
There are many reasons why it could fail:
mmap
returns ENOMEM
: No memory is available since process's maximum number of mappings would have been exceeded.mmap
returns ENOMEM
: program exceed soft or hard set by the kernel.malloc
tries to write header or footer, which result allocated space be in actual physical memory. Therefore, exceeding physical memory limit. (application hits RLIMIT_AS
or RLIMIT_DATA
)Virtual: 10 bits Physical: 8 bits Page Size: 32 byte
VIRTUAL PAGE NUMBER | PHYSICAL PAGE NUMBER | VALID |
---|---|---|
00 | 2 | 1 |
01 | - | 0 |
02 | 7 | 1 |
03 | - | 0 |
a. Because of page size, log_2(32) = 5 bits offset. Virtual page offsets always equal to physical page offsets. b. 0x04D = 0b1001101 (note: 0x represent hex, 0b represent binary)
i. VPO: 0b01101 = 0xD
ii. VPN: 0b10 = 02
iii. Page Hit, PPA = 7
iv. 0b11101101 = 0xED
c. 0x02B = 0b101011 (note: 0x represent hex, 0b represent binary)
i. VPO: 0b01011 = 0xB
ii. VPN: 0b1 = 01
iii. Page Fault
iv. Page Fault
Table of Content