mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
- Implemented reasonable way to suspend task.
- A task that has a pending suspend would be interrupted
from its sleep via the suspender task.
- If suspend was raised and right after, task became about to sleep,
then scheduler wakes it up.
- If suspend was raised when task was in user mode, then an irq suspends it.
- Also suspends are checked at the end of a syscall so that if suspend was
raised because of a syscall from the task, the task is suspended before it
goes back to user mode.
- This mechanism is very similar to signals, and it may lead as a base for
implementing signal handling.
- Implemented common vma dropping for shadow vm object dropping and task exiting.
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
/*
|
|
* Scheduler and runqueue API definitions.
|
|
*
|
|
* Copyright (C) 2007 Bahadir Balban
|
|
*/
|
|
#ifndef __SCHEDULER_H__
|
|
#define __SCHEDULER_H__
|
|
|
|
#include <l4/generic/tcb.h>
|
|
#include INC_SUBARCH(mm.h)
|
|
#include INC_GLUE(memory.h)
|
|
|
|
/* Task priorities */
|
|
#define TASK_PRIO_MAX 10
|
|
#define TASK_PRIO_REALTIME 10
|
|
#define TASK_PRIO_PAGER 8
|
|
#define TASK_PRIO_SERVER 6
|
|
#define TASK_PRIO_NORMAL 4
|
|
#define TASK_PRIO_LOW 2
|
|
|
|
/* Ticks per second, try ticks = 1000 + timeslice = 1 for regressed preemption test. */
|
|
#define SCHED_TICKS 100
|
|
|
|
/*
|
|
* A task can run continuously at this granularity,
|
|
* even if it has a greater total time slice.
|
|
*/
|
|
#define SCHED_GRANULARITY SCHED_TICKS/10
|
|
|
|
static inline struct ktcb *current_task(void)
|
|
{
|
|
register u32 stack asm("sp");
|
|
return (struct ktcb *)(stack & (~PAGE_MASK));
|
|
}
|
|
|
|
#define current current_task()
|
|
#define need_resched (current->ts_need_resched)
|
|
|
|
|
|
void sched_init_task(struct ktcb *task, int priority);
|
|
void sched_prepare_sleep(void);
|
|
void sched_suspend_sync(void);
|
|
void sched_suspend_async(void);
|
|
void sched_resume_sync(struct ktcb *task);
|
|
void sched_resume_async(struct ktcb *task);
|
|
void scheduler_start(void);
|
|
void schedule(void);
|
|
|
|
#endif /* __SCHEDULER_H__ */
|