ArchiSys/TP/TP1/rendu/mmap.h

31 lines
849 B
C
Raw Normal View History

2024-03-26 17:06:15 +01:00
#include <stdio.h>
2024-03-27 11:07:57 +01:00
#include <stdbool.h>
2024-03-26 17:06:15 +01:00
#include "linked_list.h"
struct MMap {
2024-03-26 17:45:20 +01:00
void *memory;
int size;
int count;
struct PageInfo *support;
struct linkedList *free_list;
struct linkedList *alloc_list;
FILE *swap;
2024-03-26 17:06:15 +01:00
};
struct PageInfo {
2024-03-26 17:45:20 +01:00
int key;
void *data;
2024-03-26 17:06:15 +01:00
};
struct MMap* mmap_init();
void mmap_clean(struct MMap *mmap);
struct PageInfo* page_alloc(struct MMap *mmap);
struct PageInfo* page_free(struct MMap *mmap);
int check_page_free_list(struct MMap *mmap);
int check_page_alloc(struct MMap *mmap);
int move_to_swap(struct MMap *mmap, struct PageInfo *page);
struct PageInfo* read_from_swap(struct MMap* mmap, struct PageInfo *page);
2024-03-26 17:45:20 +01:00
struct PageInfo *page_lookup(struct MMap *mmap, int key);
void page_remove(struct MMap *mmap, int key);
2024-03-27 11:07:57 +01:00
struct PageInfo *page_create(struct MMap *mmap, bool *moved_to_swap);