sched: add function to create per-cpu idle threads
This commit is contained in:
@@ -70,3 +70,21 @@ int thread_priority(struct thread *thr)
|
||||
{
|
||||
return thr->tr_prio;
|
||||
}
|
||||
|
||||
struct thread *create_idle_thread(void)
|
||||
{
|
||||
struct task *idle = idle_task();
|
||||
|
||||
struct thread *thr = thread_alloc();
|
||||
|
||||
thr->tr_prio = PRIO_NORMAL;
|
||||
thr->tr_state = THREAD_READY;
|
||||
thr->tr_quantum_target = default_quantum();
|
||||
|
||||
unsigned long flags;
|
||||
task_lock_irqsave(idle, &flags);
|
||||
queue_push_back(&idle->t_threads, &thr->tr_threads);
|
||||
task_unlock_irqrestore(idle, flags);
|
||||
|
||||
return thr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user