lock: merge spinlock and mtx locks into one

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-13 14:19:10 -04:00
commit 2076f1dae1
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
32 changed files with 158 additions and 169 deletions

View file

@ -19,9 +19,9 @@ tid_t alloc_tid()
void thread_mmap(struct thread *thread, paddr_t p, vaddr_t v, size_t len, u64 flags)
{
spinlock_acquire(&thread->mem_lock);
spin_lock(&thread->mem_lock);
page_map(thread->pgd, p, v, len, flags, &thread->memmap);
spinlock_release(&thread->mem_lock);
spin_unlock(&thread->mem_lock);
}
void *thread_alloc(struct thread *thread, size_t size)
@ -31,8 +31,8 @@ void *thread_alloc(struct thread *thread, size_t size)
static int copy_parent_memmap(struct thread *child, struct thread *parent)
{
spinlock_acquire(&parent->mem_lock);
spinlock_acquire(&child->mem_lock);
spin_lock(&parent->mem_lock);
spin_lock(&child->mem_lock);
rbnode_t *node = parent->memmap.root;
if (!node)
@ -46,8 +46,8 @@ static int copy_parent_memmap(struct thread *child, struct thread *parent)
void *pages = kalloc(area->len, ALLOC_USER);
if (!pages) {
spinlock_release(&child->mem_lock);
spinlock_release(&parent->mem_lock);
spin_unlock(&child->mem_lock);
spin_unlock(&parent->mem_lock);
return -ENOMEM;
}
@ -58,8 +58,8 @@ static int copy_parent_memmap(struct thread *child, struct thread *parent)
}
done:
spinlock_release(&child->mem_lock);
spinlock_release(&parent->mem_lock);
spin_unlock(&child->mem_lock);
spin_unlock(&parent->mem_lock);
return 0;
}
@ -119,14 +119,14 @@ struct thread *thread_fork(struct thread *parent)
return NULL;
}
spinlock_acquire(&parent->fd_lock);
spin_lock(&parent->fd_lock);
if (parent->fd_array_size) {
child->fd_array_size = parent->fd_array_size;
child->fdt = kalloc(child->fd_array_size * sizeof(struct file), ALLOC_KERN);
if (child->fdt)
memcpy(child->fdt, parent->fdt, child->fd_array_size * sizeof(struct file));
}
spinlock_release(&parent->fd_lock);
spin_unlock(&parent->fd_lock);
child->group = child->tid;