This commit is contained in:
2025-09-03 12:18:38 +02:00
parent d523d15990
commit 990b724df5
12 changed files with 15 additions and 21 deletions

View File

@@ -50,17 +50,17 @@ man proc_pid_maps
#### Ex2
L'interface (pseudo-fichier) `proc/pid/smaps` montre la consommation mémoire
d'un processus. On peut le formater avec la commande `pmap -X` ou avec le script
d'un processus. On peut le formater avec la commande `pmap -x|X` ou avec le script
python [parse_smaps.py](./src/scripts/parse_smaps.py). Le but de l'exercice est
de voir ce qui se passe au niveau de la mémoire d'un processus suivant les
différents mode d'allocation. Le programme `null.c` permet d'avoir un point de
comparaison. Vérifiez la consommation mémoire dans les cas suivants :
1. Allocation statique [buf.c](./src/ex3/buf.c).
2. Allocation sur la pile [stack.c](./src/ex3/stack.c),
3. Allocation sur le tas [heap.c](./src/ex3/heap.c),
4. Allocation (grande quantité) sur le tas [huge.c](./src/ex3/huge.c).
5. Allocation par mapping [mmap.c](./src/ex3/mmap.c).
1. Allocation statique [buf.c](./src/ex2/buf.c).
2. Allocation sur la pile [stack.c](./src/ex2/stack.c),
3. Allocation sur le tas [heap.c](./src/ex2/heap.c),
4. Allocation (grande quantité) sur le tas [huge.c](./src/ex2/huge.c).
5. Allocation par mapping [mmap.c](./src/ex2/mmap.c).
#### Ex3

9
tp/tp1/src/ex2/buf.c Normal file
View File

@@ -0,0 +1,9 @@
#include "helpers.h"
static char buffer[16 MB] = {0};
int main(int argc, char **argv)
{
randomize(buffer, 16 MB);
return interlude();
}

View File

@@ -1,15 +0,0 @@
#include "helpers.h"
#include <stdio.h>
static char buf[16 MB] = {0};
int main(int argc, char **argv)
{
buf[0] = 12;
long int ad;
printf("buf = %p\n",buf);
ad = (long int)buf;
ad = (ad & 0xfffffffff000) + 0x1000 - ad ;
buf[ad - 1] = 13;
//randomize(buf, 16 MB);
return interlude();
}