lunes, 31 de octubre de 2011

Virtual Memory

The virtual memory is the separation between logical and physical memory. It makes life easier to programmers because they don´t have to worry about the physical memory available anymore.

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.
 
Page Replacement AlgorithmsIn the next table we have differents page replacement algorithms and this show the probles that have each one.




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)


////////////////////////////////////////////////////////////////////////////
struct
array //data or elements initialized

a = null //count
create b //this is the queue

if array not avaible
return true
else
return false

if b = full
return false
new space 
move data to space
pointer new element/data

if b = null
b address new data
else
set pointer next address
a++

if b = null
return false
move data add pointer
of d to data.
////////////////////////////////////////////////////////////







1 comentario:

  1. Estudios sobre el desempeño de memoria virtual +1 (esto es más bien una discusión)

    Explicación en pseudocódigo sobre el funcionamiento de VM +1 (está sí se me hace un poco más completa, aunque su FIFO no pinta como algo muy específico de paginación).

    ResponderEliminar