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

@ -7,24 +7,24 @@
static struct {
struct thread *head;
struct thread *tail;
spinlock_t lock;
lock_t lock;
} sched_queue;
void sched_add_thread(struct thread *t)
{
spinlock_acquire(&sched_queue.lock);
spin_lock(&sched_queue.lock);
t->next = NULL;
if (sched_queue.tail)
sched_queue.tail->next = t;
sched_queue.tail = t;
if (!sched_queue.head)
sched_queue.head = t;
spinlock_release(&sched_queue.lock);
spin_unlock(&sched_queue.lock);
}
void sched_remove_thread(struct thread *del)
{
spinlock_acquire(&sched_queue.lock);
spin_lock(&sched_queue.lock);
struct thread *t = sched_queue.head;
struct thread *p = NULL;
while (t) {
@ -43,12 +43,12 @@ void sched_remove_thread(struct thread *del)
p = t;
t = t->next;
}
spinlock_release(&sched_queue.lock);
spin_unlock(&sched_queue.lock);
}
static struct thread *dequeue_thread()
{
spinlock_acquire(&sched_queue.lock);
spin_lock(&sched_queue.lock);
struct thread *t = sched_queue.head;
if (t) {
sched_queue.head = t->next;
@ -58,7 +58,7 @@ static struct thread *dequeue_thread()
} else {
t = tls_get()->idle_thread;
}
spinlock_release(&sched_queue.lock);
spin_unlock(&sched_queue.lock);
return t;
}