lock: merge spinlock and mtx locks into one
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
3e5abada9b
commit
2076f1dae1
32 changed files with 158 additions and 169 deletions
10
mem/slab.c
10
mem/slab.c
|
|
@ -2,7 +2,7 @@
|
|||
#include <kernel/mem.h>
|
||||
#include <kernel/buddy.h>
|
||||
#include <kernel/slab.h>
|
||||
#include <kernel/spinlock.h>
|
||||
#include <kernel/lock.h>
|
||||
|
||||
#include <lib/string.h>
|
||||
#include <lib/stdio.h>
|
||||
|
|
@ -50,7 +50,7 @@ void *slab_alloc(mem_cache_t *cache)
|
|||
return NULL;
|
||||
|
||||
void *ret = NULL;
|
||||
spinlock_acquire(&cache->lock);
|
||||
spin_lock(&cache->lock);
|
||||
|
||||
if (cache->num_free > 0) {
|
||||
u64 *next = (u64 *)cache->next_free;
|
||||
|
|
@ -67,7 +67,7 @@ void *slab_alloc(mem_cache_t *cache)
|
|||
ret = slab_alloc(cache->next);
|
||||
}
|
||||
|
||||
spinlock_release(&cache->lock);
|
||||
spin_unlock(&cache->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ void slab_free(mem_cache_t *cache, void *ptr)
|
|||
vaddr_t pcache = (vaddr_t)cache;
|
||||
vaddr_t pcache_start = pcache + cache->offset;
|
||||
|
||||
spinlock_acquire(&cache->lock);
|
||||
spin_lock(&cache->lock);
|
||||
|
||||
if (pptr >= pcache_start && pptr <= pcache_start + (cache->num_members - 1) * cache->item_size) {
|
||||
if ((pptr - pcache_start) % cache->item_size) {
|
||||
|
|
@ -103,7 +103,7 @@ void slab_free(mem_cache_t *cache, void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
spinlock_release(&cache->lock);
|
||||
spin_unlock(&cache->lock);
|
||||
}
|
||||
|
||||
void cleanup_kfree(void **ptr)
|
||||
|
|
|
|||
Loading…
Reference in a new issue