OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [include/] [l4/] [generic/] [scheduler.h] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Scheduler and runqueue API definitions.
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#ifndef __SCHEDULER_H__
7
#define __SCHEDULER_H__
8
 
9
#include <l4/generic/tcb.h>
10
#include <l4/generic/smp.h>
11
#include INC_SUBARCH(cpu.h)
12
#include INC_SUBARCH(mm.h)
13
#include INC_GLUE(memory.h)
14
#include INC_GLUE(smp.h)
15
 
16
/* Task priorities */
17
#define TASK_PRIO_MAX           10
18
#define TASK_PRIO_REALTIME      10
19
#define TASK_PRIO_PAGER         8
20
#define TASK_PRIO_SERVER        6
21
#define TASK_PRIO_NORMAL        4
22
#define TASK_PRIO_LOW           2
23
#define TASK_PRIO_TOTAL         30
24
 
25
/*
26
 * CONFIG_SCHED_TICKS gives ticks per second.
27
 * try ticks = 1000, and timeslice = 1 for regressed preemption test.
28
 */
29
 
30
/*
31
 * A task can run continuously at this granularity,
32
 * even if it has a greater total time slice.
33
 */
34
#define SCHED_GRANULARITY                       CONFIG_SCHED_TICKS/10
35
 
36
static inline struct ktcb *current_task(void)
37
{
38
        register u32 stack asm("sp");
39
        return (struct ktcb *)(stack & (~PAGE_MASK));
40
}
41
 
42
#define current                 current_task()
43
#define need_resched            (current->ts_need_resched)
44
 
45
#define SCHED_RQ_TOTAL                  4
46
 
47
/* A basic runqueue */
48
struct runqueue {
49
        struct scheduler *sched;
50
        struct spinlock lock;           /* Lock */
51
        struct link task_list;          /* List of tasks in rq */
52
        unsigned int total;             /* Total tasks */
53
};
54
 
55
/*
56
 * Hints and flags to scheduler
57
 */
58
enum sched_flags {
59
        /* Schedule idle at a convenient time */
60
        SCHED_RUN_IDLE = (1 << 0),
61
};
62
 
63
/* Contains per-container scheduling structures */
64
struct scheduler {
65
        unsigned int flags;
66
        unsigned int task_select_ctr;
67
        struct runqueue sched_rq[SCHED_RQ_TOTAL];
68
 
69
        /* Regular runqueues */
70
        struct runqueue *rq_runnable;
71
        struct runqueue *rq_expired;
72
 
73
        /* Real-time runqueues */
74
        struct runqueue *rq_rt_runnable;
75
        struct runqueue *rq_rt_expired;
76
 
77
        struct ktcb *idle_task;
78
 
79
        /* Total priority of all tasks in container */
80
        int prio_total;
81
};
82
 
83
DECLARE_PERCPU(extern struct scheduler, scheduler);
84
 
85
void sched_init_runqueue(struct scheduler *sched, struct runqueue *rq);
86
void sched_init_task(struct ktcb *task, int priority);
87
void sched_prepare_sleep(void);
88
void sched_suspend_sync(void);
89
void sched_suspend_async(void);
90
void sched_resume_sync(struct ktcb *task);
91
void sched_resume_async(struct ktcb *task);
92
void sched_enqueue_task(struct ktcb *first_time_runner, int sync);
93
void scheduler_start(void);
94
void schedule(void);
95
void sched_init(void);
96
void idle_task(void);
97
 
98
#endif /* __SCHEDULER_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.