sched: add function to create per-cpu idle threads
This commit is contained in:
@@ -156,6 +156,9 @@ static inline void task_unlock_irqrestore(struct task *task, unsigned long flags
|
|||||||
extern struct thread *thread_alloc(void);
|
extern struct thread *thread_alloc(void);
|
||||||
extern kern_status_t thread_init(struct thread *thr, uintptr_t ip);
|
extern kern_status_t thread_init(struct thread *thr, uintptr_t ip);
|
||||||
extern int thread_priority(struct thread *thr);
|
extern int thread_priority(struct thread *thr);
|
||||||
|
extern void idle(void);
|
||||||
|
|
||||||
|
extern struct thread *create_idle_thread(void);
|
||||||
|
|
||||||
extern void add_timer(struct timer *timer);
|
extern void add_timer(struct timer *timer);
|
||||||
extern void remove_timer(struct timer *timer);
|
extern void remove_timer(struct timer *timer);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ struct task *idle_task(void)
|
|||||||
return __idle_task;
|
return __idle_task;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __idle_function(void)
|
void idle(void)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
ml_cpu_pause();
|
ml_cpu_pause();
|
||||||
@@ -123,7 +123,7 @@ kern_status_t setup_idle_task(void)
|
|||||||
|
|
||||||
idle_thread->tr_id = 0;
|
idle_thread->tr_id = 0;
|
||||||
idle_thread->tr_parent = __idle_task;
|
idle_thread->tr_parent = __idle_task;
|
||||||
thread_init(idle_thread, (uintptr_t)__idle_function);
|
thread_init(idle_thread, (uintptr_t)idle);
|
||||||
|
|
||||||
queue_push_back(&__idle_task->t_threads, &idle_thread->tr_threads);
|
queue_push_back(&__idle_task->t_threads, &idle_thread->tr_threads);
|
||||||
|
|
||||||
|
|||||||
@@ -70,3 +70,21 @@ int thread_priority(struct thread *thr)
|
|||||||
{
|
{
|
||||||
return thr->tr_prio;
|
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