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
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue