sched: add function to create per-cpu idle threads

This commit is contained in:
2023-05-03 19:27:18 +01:00
parent ad58693dfb
commit c64577e24e
3 changed files with 23 additions and 2 deletions

View File

@@ -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;
}