diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-02 18:21:59 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-02 18:21:59 +0100 |
commit | 1a5c518ee1536db50dccd8766ce78c3790aec059 (patch) | |
tree | 0605cabbb817270a4484d2eb8d33b615006e71ce /src/kernel/core/paging.c | |
parent | ceb687b02964197133fd2236cdbc74bf3948d034 (diff) | |
download | kogata-1a5c518ee1536db50dccd8766ce78c3790aec059.tar.gz kogata-1a5c518ee1536db50dccd8766ce78c3790aec059.zip |
More uses of free_some_memory()
Diffstat (limited to 'src/kernel/core/paging.c')
-rw-r--r-- | src/kernel/core/paging.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/kernel/core/paging.c b/src/kernel/core/paging.c index 0b46be1..38e8407 100644 --- a/src/kernel/core/paging.c +++ b/src/kernel/core/paging.c @@ -6,6 +6,7 @@ #include <mutex.h> #include <thread.h> #include <malloc.h> +#include <freemem.h> #define PAGE_OF_ADDR(x) (((size_t)(x) >> PAGE_SHIFT) % N_PAGES_IN_PT) #define PT_OF_ADDR(x) ((size_t)(x) >> (PAGE_SHIFT + PT_SHIFT)) @@ -210,10 +211,17 @@ bool pd_map_page(void* vaddr, uint32_t frame_id, bool rw) { mutex_lock(&pdd->mutex); if (!(pd->page[pt] & PTE_PRESENT)) { - uint32_t new_pt_frame = frame_alloc(1); + + uint32_t new_pt_frame; + int tries = 0; + while ((new_pt_frame = frame_alloc(1)) == 0 && (tries++) < 3) { + mutex_unlock(&pdd->mutex); + free_some_memory(); + mutex_lock(&pdd->mutex); + } if (new_pt_frame == 0) { mutex_unlock(&pdd->mutex); - return false; // OOM + return false; } current_pd->page[pt] = pd->page[pt] = |