-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemList.h
66 lines (48 loc) · 1.55 KB
/
MemList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef CLION_MEMLIST_H
#define CLION_MEMLIST_H
#include <stdbool.h>
#include <bits/types/time_t.h>
#include <unistd.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <time.h>
/* INFORMACION DE LA LISTA
• Its memory address
• Its size
• Time of allocation
• Type of allocation (malloc memory, shared memory, mapped file)
• Other info: key for shared memory blocks, name of file and file descriptor for mapped files
*/
typedef struct MNode* MPos;
typedef struct Block {
void *dir; // Direccion de memoria
size_t size; // Tamaño del bloque de memoria
char time[20]; // Time of allocation
char type[20]; // Type of allocation
int key; // Key (shared)
char name[50]; // Nombre del fichero (mmap)
int df; // File descrptor (mmap)
} Block;
struct MNode {
Block data;
MPos next;
};
typedef MPos MemList;
/* Funciones */
void createMemList (MemList *L);
/*
MPos first(MemList head);
MPos last(MemList head); */
bool createMNode(MPos *p);
bool InsertarNodoMalloc(MemList *L, struct MNode *block);
bool InsertarNodoShared(MemList *L, MPos *p, size_t size, key_t clave);
bool InsertarNodoMmap(MemList *MP, MPos *p, size_t size, int df, char *fichero);
void deleteAtPosition(MPos p, MemList *L);
int deleteAddr(char *dir, MemList M, MemList S, MemList MP);
void deleteMemList(MemList *L);
void printMemList(MemList L, int op);
void printMemList2(MemList L, MemList S, MemList MP);
MPos findKeyBlock(int clave, MemList L);
MPos findBlock(int tam, MemList L);
MPos findMmapBlock(char *name, MemList L);
#endif //CLION_MEMLIST_H