sched: add timer tasks and schedule_timeout()
This commit is contained in:
@@ -20,6 +20,7 @@ struct cpu_data {
|
||||
unsigned int c_preempt_count;
|
||||
|
||||
struct runqueue c_rq;
|
||||
struct queue c_timers;
|
||||
};
|
||||
|
||||
/* maximum number of processor cores that the kernel can support.
|
||||
|
||||
@@ -41,6 +41,17 @@ enum sched_priority {
|
||||
PRIO_REALTIME = 24,
|
||||
};
|
||||
|
||||
enum sched_mode {
|
||||
/* used when calling from non-interrupt context.
|
||||
threads that aren't in state THREAD_READY are
|
||||
removed from the runqueue. */
|
||||
SCHED_NORMAL = 0,
|
||||
/* used when calling from interrupt context.
|
||||
threads that aren't in state THREAD_READY are
|
||||
still added to the runqueue. */
|
||||
SCHED_IRQ = 1,
|
||||
};
|
||||
|
||||
struct task {
|
||||
struct task *t_parent;
|
||||
unsigned int t_id;
|
||||
@@ -82,8 +93,26 @@ struct runqueue {
|
||||
struct thread *rq_cur, *rq_idle;
|
||||
};
|
||||
|
||||
struct timer {
|
||||
struct queue_entry t_entry;
|
||||
struct cpu_data *t_cpu;
|
||||
struct thread *t_owner;
|
||||
unsigned long t_expiry;
|
||||
void(*t_callback)(struct timer *);
|
||||
};
|
||||
|
||||
struct wait_item {
|
||||
struct thread *w_thread;
|
||||
struct queue_entry w_entry;
|
||||
};
|
||||
|
||||
struct waitqueue {
|
||||
struct queue wq_waiters;
|
||||
spin_lock_t wq_lock;
|
||||
};
|
||||
|
||||
extern kern_status_t sched_init(void);
|
||||
extern void schedule(void);
|
||||
extern void schedule(enum sched_mode mode);
|
||||
extern void preempt_disable(void);
|
||||
extern void preempt_enable(void);
|
||||
|
||||
@@ -128,6 +157,11 @@ extern struct thread *thread_alloc(void);
|
||||
extern kern_status_t thread_init(struct thread *thr, uintptr_t ip);
|
||||
extern int thread_priority(struct thread *thr);
|
||||
|
||||
extern void add_timer(struct timer *timer);
|
||||
extern void remove_timer(struct timer *timer);
|
||||
extern unsigned long schedule_timeout(unsigned long clock_ticks);
|
||||
extern unsigned long milli_sleep(unsigned long ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user