aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHennadiy Leontyev <leontyev@jupiter-cs.cs.unc.edu>2007-02-28 01:12:54 -0500
committerHennadiy Leontyev <leontyev@jupiter-cs.cs.unc.edu>2007-02-28 01:12:54 -0500
commit5637daed062ac00ab1b2a672ebeb662c2f05fb98 (patch)
tree3321f3c8266f47e7a8e0037661d7bb37d8e1782b /include
parent4300134c74385b82710672cb25f604ade97f334d (diff)
PFAIR scheduling added
Diffstat (limited to 'include')
-rw-r--r--include/linux/pfair_common.h40
-rw-r--r--include/linux/pfair_math.h75
-rw-r--r--include/linux/rt_param.h53
3 files changed, 149 insertions, 19 deletions
diff --git a/include/linux/pfair_common.h b/include/linux/pfair_common.h
new file mode 100644
index 0000000000..67e18c601a
--- /dev/null
+++ b/include/linux/pfair_common.h
@@ -0,0 +1,40 @@
1/* PFAIR common data structures and utility functions shared by all PFAIR
2 * based scheduler plugins
3 */
4
5#ifndef __UNC_PFAIR_COMMON_H__
6#define __UNC_PFAIR_COMMON_H__
7
8#include <linux/queuelock.h>
9#include <linux/cpumask.h>
10
11typedef struct _pfair_domain {
12 /* Global lock to protect the data structures */
13 queuelock_t pfair_lock;
14 /* runnable rt tasks are in here */
15 struct list_head ready_queue;
16
17 /* real-time tasks waiting for release are in here */
18 struct list_head release_queue;
19
20 /* CPU's in the domain */
21 cpumask_t domain_cpus;
22
23} pfair_domain_t;
24
25#define next_ready(pfair) \
26 (list_entry((pfair)->ready_queue.next, struct task_struct, rt_list))
27void pfair_domain_init(pfair_domain_t *pfair);
28void pfair_add_ready(pfair_domain_t* pfair, struct task_struct *new);
29struct task_struct* __pfair_take_ready(pfair_domain_t* pfair);
30void pfair_add_release(pfair_domain_t* pfair, struct task_struct *task);
31void pfair_try_release_pending(pfair_domain_t* pfair);
32void __pfair_prepare_new_release(struct task_struct *t, jiffie_t start);
33
34void pfair_prepare_next_job(struct task_struct *t);
35void pfair_prepare_next_subtask(struct task_struct *t);
36
37void pfair_prepare_new_releases(pfair_domain_t *pfair, jiffie_t start);
38
39#endif
40
diff --git a/include/linux/pfair_math.h b/include/linux/pfair_math.h
new file mode 100644
index 0000000000..6eef12433c
--- /dev/null
+++ b/include/linux/pfair_math.h
@@ -0,0 +1,75 @@
1/* PFAIR Mathematical functions */
2#ifndef __UNC_PFAIR_MATH_H__
3#define __UNC_PFAIR_MATH_H__
4
5#include <linux/rt_param.h>
6#include <asm/div64.h>
7#include <linux/litmus.h>
8#include <linux/sched.h>
9
10/*
11* This file defines mathematical functions "ceiling", "floor",
12* and PFAIR specific functions for computing the release and
13* the deadline of a subtask, as well as tie breakers:
14* b-bit and group deadline.
15*/
16static inline quantum_t FLOOR(quantum_t a, unsigned long b)
17{
18 BUG_ON( b == 0);
19 do_div(a, b);
20 return a;
21}
22static inline quantum_t CEIL(quantum_t a, unsigned long b)
23{
24 quantum_t t = FLOOR(a, b);
25 return (quantum_t)((t * b == a)?t:(t + 1));
26}
27
28
29/*
30* invariant - i-1=get_passed_quanta(t)
31*
32* release time of i-th subtask of j-th job is
33* r_{ij}+\lfloor i-1/wt(T) \rfloor
34* This operation should be robust to wrap-around
35* so we can compare the result with jiffies safely
36*/
37static inline quantum_t release_time(struct task_struct * t)
38{
39 quantum_t e = get_exec_cost(t);
40 quantum_t p = get_rt_period(t);
41 return FLOOR((get_passed_quanta(t)) * p, e);
42}
43/*
44* deadline time of i-th subtask of j-th job is
45* r_{ij}+\lceil i/wt(T) \rceil
46* This operation should be robust to wrap-around
47* so we can compare the result with jiffies safely
48*/
49static inline quantum_t pfair_deadline(struct task_struct * t)
50{
51 quantum_t e = get_exec_cost(t);
52 quantum_t p = get_rt_period(t);
53 return CEIL((get_passed_quanta(t) + 1) * p, e);
54}
55/* In PFAIR b-bit is defined as
56* \lceil i/wt(T) \rceil-\lfloor i/wt(T) \rfloor
57*/
58static inline int b_bit(struct task_struct *t)
59{
60 quantum_t e = get_exec_cost(t);
61 quantum_t p = get_rt_period(t);
62 return CEIL((get_passed_quanta(t) + 1) * p, e)-
63 FLOOR((get_passed_quanta(t) + 1)* p, e);
64}
65/*
66* Group deadline
67*/
68static inline quantum_t group_deadline(struct task_struct * t)
69{
70 quantum_t p = get_rt_period(t);
71 quantum_t e = get_exec_cost(t);
72 return CEIL(CEIL(CEIL((get_passed_quanta(t)+1)*p, e)*(p-e), p)*p, p-e);
73}
74
75#endif /* __UNC_PFAIR_MATH_H__ */
diff --git a/include/linux/rt_param.h b/include/linux/rt_param.h
index 1247a2ab22..0c5facd005 100644
--- a/include/linux/rt_param.h
+++ b/include/linux/rt_param.h
@@ -21,6 +21,30 @@ typedef struct rt_param {
21 task_class_t class; 21 task_class_t class;
22} rt_param_t; 22} rt_param_t;
23 23
24typedef struct {
25 /* when will this task be release the next time? */
26 jiffie_t release;
27 /* time instant the last job was released */
28 jiffie_t last_release;
29 /* what is the current deadline? */
30 jiffie_t deadline;
31 /* b-bit tie breaker for PFAIR, it is ignored in EDF */
32 int b_bit;
33 /* group deadline tie breaker, it is ignored in EDF */
34 jiffie_t group_deadline;
35 /* how long has this task executed so far?
36 * In case of capacity sharing a job completion cannot be
37 * detected by checking time_slice == 0 as the job may have
38 * executed while using another capacity. Use this counter
39 * to keep track of the time spent on a CPU by a job.
40 *
41 * In other words: The number of consumed quanta since the
42 * last job release.
43 */
44 unsigned int exec_time;
45} in_times_t;
46
47
24/* RT task parameters for scheduling extensions 48/* RT task parameters for scheduling extensions
25 * These parameters are inherited during clone and therefore must 49 * These parameters are inherited during clone and therefore must
26 * be explicitly set up before the task set is launched. 50 * be explicitly set up before the task set is launched.
@@ -32,25 +56,6 @@ typedef struct task_rt_param {
32 rt_param_t basic_params; 56 rt_param_t basic_params;
33 /* is the task sleeping? */ 57 /* is the task sleeping? */
34 unsigned int flags; 58 unsigned int flags;
35 struct {
36 /* when will this task be release the next time? */
37 jiffie_t release;
38 /* time instant the last job was released */
39 jiffie_t last_release;
40 /* what is the current deadline? */
41 jiffie_t deadline;
42
43 /* how long has this task executed so far?
44 * In case of capacity sharing a job completion cannot be
45 * detected by checking time_slice == 0 as the job may have
46 * executed while using another capacity. Use this counter
47 * to keep track of the time spent on a CPU by a job.
48 *
49 * In other words: The number of consumed quanta since the
50 * last job release.
51 */
52 unsigned int exec_time;
53 } times;
54 59
55 /* put information for feedback control stuff and 60 /* put information for feedback control stuff and
56 * information about the performance of the task here 61 * information about the performance of the task here
@@ -59,6 +64,9 @@ typedef struct task_rt_param {
59 /* How many non-tardy jobs since the last tardy job? */ 64 /* How many non-tardy jobs since the last tardy job? */
60 unsigned int nontardy_jobs_ctr; 65 unsigned int nontardy_jobs_ctr;
61 } stats; 66 } stats;
67
68 in_times_t times;
69 in_times_t backup;
62 70
63 /* is this task under control of litmus? 71 /* is this task under control of litmus?
64 * 72 *
@@ -102,6 +110,9 @@ memset(&(t)->rt_param,0, sizeof(struct task_rt_param))
102#define get_last_release_time(t) ((t)->rt_param.times.last_release) 110#define get_last_release_time(t) ((t)->rt_param.times.last_release)
103#define set_last_release_time(t,r) ((t)->rt_param.times.last_releasee=(r)) 111#define set_last_release_time(t,r) ((t)->rt_param.times.last_releasee=(r))
104 112
113#define get_release(t) ((t)->rt_param.times.release)
114#define set_release(t,r) ((t)->rt_param.times.release=(r))
115
105#define is_running(t) ((t)->state == TASK_RUNNING) 116#define is_running(t) ((t)->state == TASK_RUNNING)
106#define is_released(t) (time_before_eq((t)->rt_param.times.release, jiffies)) 117#define is_released(t) (time_before_eq((t)->rt_param.times.release, jiffies))
107#define is_tardy(t) (time_before_eq((t)->rt_param.times.deadline, jiffies)) 118#define is_tardy(t) (time_before_eq((t)->rt_param.times.deadline, jiffies))
@@ -118,4 +129,8 @@ memset(&(t)->rt_param,0, sizeof(struct task_rt_param))
118 (a)->rt_param.times.release,\ 129 (a)->rt_param.times.release,\
119 (b)->rt_param.times.release)) 130 (b)->rt_param.times.release))
120 131
132#define backup_times(t) do { (t)->rt_patam.backup=(t)->rt_param.times; \
133 } while(0);
134#define restore_times(t) do { (t)->rt_patam.times=(t)->rt_param.backup; \
135 } while(0);
121#endif 136#endif