ArchiSys/TP/TP1/rendu/mmap.h

31 lines
732 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"
2024-03-29 22:46:30 +01:00
typedef struct MMap {
2024-03-26 17:45:20 +01:00
void *memory;
int size;
int count;
2024-03-29 22:46:30 +01:00
PageInfo *support;
linkedList *free_list;
linkedList *alloc_list;
2024-03-26 17:45:20 +01:00
FILE *swap;
2024-03-29 22:46:30 +01:00
} MMap;
2024-03-26 17:06:15 +01:00
2024-03-29 22:46:30 +01:00
typedef struct PageInfo {
2024-03-26 17:45:20 +01:00
int key;
void *data;
2024-03-29 22:46:30 +01:00
} PageInfo;
2024-03-26 17:06:15 +01:00
2024-03-29 22:46:30 +01:00
MMap* mmap_init();
void mmap_clean(MMap *mmap);
PageInfo* page_alloc(MMap *mmap);
PageInfo* page_free(MMap *mmap);
int check_page_free_list(MMap *mmap);
int check_page_alloc(MMap *mmap);
int move_to_swap(MMap *mmap, PageInfo *page);
PageInfo* read_from_swap(MMap* mmap, PageInfo *page);
PageInfo *page_lookup(MMap *mmap, int key);
void page_remove(MMap *mmap, int key);
PageInfo *page_create(MMap *mmap, bool *moved_to_swap);