mirror of
https://github.com/drasko/codezero.git
synced 2026-01-13 19:33:15 +01:00
- test0 now forks 16 tasks that each modify a global variable. - scheduler now gives 1/10th of a second per task. It also does not increase timeslice of a task that has scheduled. - When a memory is granted to the kernel, the distribution of this memory to memcaches was calculated in a complicated way. This is now simplified.
52 lines
1.5 KiB
C
52 lines
1.5 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)
|
|
|
|
/* Ticks per second, try ticks = 1000 + timeslice = 1 for regressed preemption test. */
|
|
#define HZ 100
|
|
#define TASK_TIMESLICE_DEFAULT HZ/100
|
|
|
|
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)
|
|
|
|
/* Flags set by kernel to direct the scheduler about future task state. */
|
|
#define __SCHED_FL_SUSPEND 1
|
|
#define SCHED_FL_SUSPEND (1 << __SCHED_FL_SUSPEND)
|
|
#define __SCHED_FL_RESUME 2
|
|
#define SCHED_FL_RESUME (1 << __SCHED_FL_RESUME)
|
|
#define __SCHED_FL_SLEEP 3
|
|
#define SCHED_FL_SLEEP (1 << __SCHED_FL_SLEEP)
|
|
#define SCHED_FL_MASK (SCHED_FL_SLEEP | SCHED_FL_RESUME \
|
|
| SCHED_FL_SUSPEND)
|
|
|
|
void sched_runqueue_init(void);
|
|
void sched_init_task(struct ktcb *task);
|
|
void sched_start_task(struct ktcb *task);
|
|
void sched_resume_task(struct ktcb *task);
|
|
void sched_suspend_task(struct ktcb *task);
|
|
void sched_tell(struct ktcb *task, unsigned int flags);
|
|
void scheduler_start(void);
|
|
void sched_yield(void);
|
|
void schedule(void);
|
|
|
|
/* Asynchronous notifications to scheduler */
|
|
void sched_notify_resume(struct ktcb *task);
|
|
void sched_notify_sleep(struct ktcb *task);
|
|
void sched_notify_suspend(struct ktcb *task);
|
|
|
|
#endif /* __SCHEDULER_H__ */
|