Managing Virtual Memory
<aside>
💡 Consider that we are creating a software that basically manages the shell for us, in this case, when the shell runs a process, we want to fork so that the process can run in a separate address space and then execute, without terminating the shell parent process
</aside>
The Downfalls of Physical Memory
- the benefits is that it is simple for hardware
- these tactics are used in embedded microcontrollers but is genuinely not used largely due to the following reasons
- fragmentation → a lot of different programs use different amounts of memory and it is hard to allocate all of the memory equally when these numbers are constantly changing
- no solution when we are out of memory
- lots of burden to figure out what the memory limitations are
Strategy of Using Virtual Memory
- the cpu passes the virtual memory address through the memory management unit which then converts into the physical address within the memory
- It makes distinguishing addresses from different processes easier
- paging logically divides the memory into chunks that are called pages
- any virtual page can be mapped to any physical page → that is fully associated
- translating VA to PA before accessing cache is done bc it makes distinguishing addresses from different processes easier
- WHENEVER YOU PRINT ADDRESS, IT IS VIRTUAL
- this occurs because all of the translations are for the virtual address and each process does not “own” a physical memory location
Benefits of Virtual Memory
- allows for isolating address spaces for different process
- it allows the address space to be larger than the physical address space
- Multi-level allows for less bits to the block offset due to using another thing for indexing into the level
- uses both spatial and prime locality
Pages
- Page size is 0x1000 bytes = 2^12