There is something about AS in Linux(2)

AS = ADDRESS SPACE

Each process is assigned by the OS a physical memory region (a physical address space).

0- Init

Look at this visual : two processes A and B nicely living together in the memory

No alt text provided for this image

The oversimplified model I provided (part1) is based on this simple concept: The OS with a full support from the hardware could access the process physical space using a data structure called "process table" by translating the virtual address to corresponding physical address. The processor is supposed to have two registers Base register and Bound registers :

No alt text provided for this image

II- Two visions

No alt text provided for this image

Note: green spaces are memory free spaces

OS "sees" the real memory region occupied by the process A [8K,12K]. The process A "thinks" that it is living in the region [0K,4K].

With the oversimplified model using base and bound registers: If the OS decided to relocate the process A, the process A's free spaces will be relocated with it :

No alt text provided for this image

So, we conclude that this model is NOT flexible enough and wasteful ; During relocation, there is no need to relocate the free spaces ( green region).

The next model is called the segmentation model ( you know the infamous error segmentation fault).

III- Segmentation model

With the support of the HW, the OS decompose Process A's memory into three logical segments:

  • Code segment
  • Heap Segment
  • Stack segment

Each segment is bounded to a pair of Base and Bound registers.So, We will have 3 pairs of base and bound registers:

No alt text provided for this image

Suppose that in your program A (Process A) you want to access the Virtual address 0x00F. How the OS would manage to find out the segment containing this address?

The virtual address in the segmentation model is composed of two parts:

0x||segment address||Cell Address within the segment||.

Suppose the segment address is coded on two bits. let's decompose 0x00F:

0x ||00||0000 1111||

00 = Code segment, 01= Heap Segment, 10= Stack segment

IV- Procedure

VA= Virtual Address, PA= Physical Address

Details of "algorithm" used by the processor and hardware to locate the address 0x00F:

0x ||00||0000 1111||

VA(code segment)=00 =>With the hep of Process Table=> PA(code segment)=12K

0000 1111 is the address of the cell located within the Code Segment

VA(cell) =0000 1111 => PA(cell) = PA(code segment) + offset= 12K + 0000 1111

Then the processor will test if PA(cell) is less than 13K. If the PA(cell) is not within the authorized range,the address is illegal, in this case asegmentation fault will be raised and the offended process is killed.

Happy AS

To view or add a comment, sign in

More articles by A. ADELL

  • Produit et propriétés universelles

    note: article en cours ① Mise en jambe Soient A , B, P et C des ensembles ayant les extensions suivantes: A= { John…

  • La correction du gamma

    «La correction du gamma permet de définir la quantité relative des composantes de couleur d’une image. Cette fonction…

  • Sections PLT, GOT, compilation statique vs dynamique

    De nombreux articles sur Internet expliquent les notions de compilation statique et dynamique et le rôle de PLT et GOT…

  • Re-entrancy attack sur "The DAO" & smart contract

    Voilà une attaque malicieuse qui date de 2016 sur les smart contracts! L'initiation des smart contracts sur la…

  • SVD, Data Science, et algèbre linéaire

    SVD = Singular Value Decomposition (Décomposition en valeurs singulières) Mise en jambes Soit 𝔼 un K-espace vectoriel…

  • un peu de (mécanique) quantique (2/10)

    Je considère un système à un seul qubit 1️⃣ vecteur d'état pour les états purs La base considérée est {|uᵢ⟩}, i =1,..

  • Pourquoi "positiver"

    Désolé ce n'est pas un article sur les astuces pour rester positif! 1️⃣ Rester "positif" ! Je considère l'opération de…

  • un peu de (mécanique) quantique

    Système à un seul qubit Un qubit correspond à l'état d'une particule qui peut osciller entre deux états de base: par…

  • Entropie en thermodynamique vs Entropie en théorie de l'information

    Introduction Emmy Noether,mathématicienne allemande, a démontré le théorème suivant : Parce que les lois physiques…

  • md5

    I- Empreinte Les fichiers informatiques ont leurs empreintes aussi!. Le calcul de l'empreinte d'un document emploie une…

Others also viewed

Explore content categories