Properly implement liballoc_free ()
This commit is contained in:
17
kernel/proc/mem.c
Normal file
17
kernel/proc/mem.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <libk/std.h>
|
||||
#include <proc/mem.h>
|
||||
#include <proc/proc.h>
|
||||
#include <proc/resource.h>
|
||||
#include <sync/spin_lock.h>
|
||||
|
||||
void proc_mem_unref (struct proc* proc, struct proc_resource_mem* mem, size_t pages) {
|
||||
spin_lock_ctx_t ctxrs;
|
||||
|
||||
spin_lock (&mem->resource->lock, &ctxrs);
|
||||
mem->alive_pages -= pages;
|
||||
ptrdiff_t current_pages = mem->alive_pages;
|
||||
spin_unlock (&mem->resource->lock, &ctxrs);
|
||||
|
||||
if (current_pages <= 0)
|
||||
proc_drop_resource (proc, mem->resource);
|
||||
}
|
||||
Reference in New Issue
Block a user