thread: move thread awaken functionality to a dedicated function
This commit is contained in:
@@ -127,6 +127,17 @@ int thread_priority(struct thread *thr)
|
|||||||
return thr->tr_prio;
|
return thr->tr_prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_awaken(struct thread *thr)
|
||||||
|
{
|
||||||
|
struct runqueue *rq = thr->tr_rq;
|
||||||
|
if (!rq) {
|
||||||
|
rq = cpu_rq(this_cpu());
|
||||||
|
}
|
||||||
|
|
||||||
|
thr->tr_state = THREAD_READY;
|
||||||
|
rq_enqueue(rq, thr);
|
||||||
|
}
|
||||||
|
|
||||||
struct thread *create_kernel_thread(void (*fn)(void))
|
struct thread *create_kernel_thread(void (*fn)(void))
|
||||||
{
|
{
|
||||||
struct task *kernel = kernel_task();
|
struct task *kernel = kernel_task();
|
||||||
|
|||||||
16
sched/wait.c
16
sched/wait.c
@@ -36,15 +36,10 @@ void wakeup_queue(struct waitqueue *q)
|
|||||||
spin_lock_irqsave(&q->wq_lock, &flags);
|
spin_lock_irqsave(&q->wq_lock, &flags);
|
||||||
struct queue_entry *ent = queue_pop_front(&q->wq_waiters);
|
struct queue_entry *ent = queue_pop_front(&q->wq_waiters);
|
||||||
while (ent) {
|
while (ent) {
|
||||||
struct wait_item *waiter = QUEUE_CONTAINER(struct wait_item, w_entry, ent);
|
struct wait_item *waiter
|
||||||
|
= QUEUE_CONTAINER(struct wait_item, w_entry, ent);
|
||||||
struct thread *thr = waiter->w_thread;
|
struct thread *thr = waiter->w_thread;
|
||||||
struct runqueue *rq = thr->tr_rq;
|
thread_awaken(thr);
|
||||||
if (!rq) {
|
|
||||||
rq = cpu_rq(this_cpu());
|
|
||||||
}
|
|
||||||
|
|
||||||
thr->tr_state = THREAD_READY;
|
|
||||||
rq_enqueue(rq, thr);
|
|
||||||
|
|
||||||
ent = queue_pop_front(&q->wq_waiters);
|
ent = queue_pop_front(&q->wq_waiters);
|
||||||
}
|
}
|
||||||
@@ -57,8 +52,9 @@ void wakeup_one(struct waitqueue *q)
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
spin_lock_irqsave(&q->wq_lock, &flags);
|
spin_lock_irqsave(&q->wq_lock, &flags);
|
||||||
struct queue_entry *ent = queue_pop_front(&q->wq_waiters);
|
struct queue_entry *ent = queue_pop_front(&q->wq_waiters);
|
||||||
if(ent) {
|
if (ent) {
|
||||||
struct wait_item *waiter = QUEUE_CONTAINER(struct wait_item, w_entry, ent);
|
struct wait_item *waiter
|
||||||
|
= QUEUE_CONTAINER(struct wait_item, w_entry, ent);
|
||||||
struct thread *thr = waiter->w_thread;
|
struct thread *thr = waiter->w_thread;
|
||||||
struct runqueue *rq = thr->tr_rq;
|
struct runqueue *rq = thr->tr_rq;
|
||||||
if (!rq) {
|
if (!rq) {
|
||||||
|
|||||||
Reference in New Issue
Block a user