In order to avoid external fragmentation, we can divide the information into smaller pieces called page frames, which contain the data of that page. Virtual adresses can be divided into two pieces: Page numbers and offsets within that page. 3
In order to access a piece of data at a given adress, a system first extracts both the page number and the offset. After extracting this data, the page number is translated to the physical frame id, then it accesses data at offset in the physical pageframe.
When there is not enough space to run a process, we can compact or relocate it. We can also swap to the disk a process that is not being used. Then, when it becomes available we can restore the process.
When we are looking for a process that is located in disk, a page fault occur.
A translation lookaside buffer (TLB) is a cache memory administrated by the MMU. It contains slots of the page table, it also maps the relationship between virtual and physical adresses.
The page table keeps the track of where the virtual pages are loaded into the physical memory.
In the next image we have a simple psedocode of FIFO (we know that this is the less eficient, but it is the more easy for implement and combined with other structures or algorithms is more efficient)
array //data or elements initialized
a = null //count
create b //this is the queue
if array not avaible
if b = full
new spacemove data to space
pointer new element/data
if b = null
b address new data
set pointer next address
if b = null
move data add pointer
of d to data.