thread: add kthreads
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
da53fa3871
commit
54803ed29b
6 changed files with 79 additions and 36 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue