thread: add kthreads

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 22:03:52 -04:00
commit 54803ed29b
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
6 changed files with 79 additions and 36 deletions

View file

@ -2,6 +2,7 @@
#include <kernel/common.h>
#include <kernel/spinlock.h>
#include <kernel/atomic.h>
#include <kernel/thread.h>
#include <arch/proc.h>
static uint64_t spinlock_attempt_acquire(spinlock_t *lock)
@ -29,7 +30,7 @@ void cleanup_spinlock(spinlock_t **lock_ptr)
void mtx_lock(mtx_t *l)
{
while (spinlock_attempt_acquire(l))
thread_wait();
reschedule(THREAD_STATE_WAITING);
}
void mtx_unlock(mtx_t *l)