diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2013-03-13 17:24:27 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2013-03-13 17:24:27 -0400 |
commit | 020dc974933f4e9459f699625a138c33811eadf6 (patch) | |
tree | d45dbe70b7fc3ce0655baeda609ad452a2840ac2 /src/litmus.c | |
parent | 944a78c21028da69fb53c0aec3e9dfdb048d47e4 (diff) | |
parent | 0e71f86251307a37161cf3de2704a59882e25258 (diff) |
Merge branch 'prop/rt_task-init-final' into temp
Conflicts:
bin/base_mt_task.c
bin/rt_launch.c
bin/rtspin.c
include/litmus.h
src/litmus.c
src/task.c
Diffstat (limited to 'src/litmus.c')
-rw-r--r-- | src/litmus.c | 103 |
1 files changed, 62 insertions, 41 deletions
diff --git a/src/litmus.c b/src/litmus.c index 7cdffcc..213ac3f 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -88,6 +88,34 @@ void show_rt_param(struct rt_task* tp) | |||
88 | tp->exec_cost, tp->period, tp->cpu); | 88 | tp->exec_cost, tp->period, tp->cpu); |
89 | } | 89 | } |
90 | 90 | ||
91 | void init_rt_task_param(struct rt_task* tp) | ||
92 | { | ||
93 | /* Defaults: | ||
94 | * - implicit deadline (t->relative_deadline == 0) | ||
95 | * - phase = 0 | ||
96 | * - class = RT_CLASS_SOFT | ||
97 | * - budget policy = NO_ENFORCEMENT | ||
98 | * - fixed priority = LITMUS_LOWEST_PRIORITY | ||
99 | * - release policy = SPORADIC | ||
100 | * - cpu assignment = 0 | ||
101 | * | ||
102 | * User must still set the following fields to non-zero values: | ||
103 | * - tp->exec_cost | ||
104 | * - tp->period | ||
105 | * | ||
106 | * User must set tp->cpu to the appropriate value for non-global | ||
107 | * schedulers. For clusters, set tp->cpu to the first CPU in the | ||
108 | * assigned cluster. | ||
109 | */ | ||
110 | |||
111 | memset(tp, 0, sizeof(*tp)); | ||
112 | |||
113 | tp->cls = RT_CLASS_SOFT; | ||
114 | tp->priority = LITMUS_LOWEST_PRIORITY; | ||
115 | tp->budget_policy = NO_ENFORCEMENT; | ||
116 | tp->release_policy = SPORADIC; | ||
117 | } | ||
118 | |||
91 | task_class_t str2class(const char* str) | 119 | task_class_t str2class(const char* str) |
92 | { | 120 | { |
93 | if (!strcmp(str, "hrt")) | 121 | if (!strcmp(str, "hrt")) |
@@ -102,57 +130,50 @@ task_class_t str2class(const char* str) | |||
102 | 130 | ||
103 | #define NS_PER_MS 1000000 | 131 | #define NS_PER_MS 1000000 |
104 | 132 | ||
105 | /* only for best-effort execution: migrate to target_cpu */ | 133 | int sporadic_global(lt_t e_ns, lt_t p_ns) |
106 | int be_migrate_to(int target_cpu) | ||
107 | { | 134 | { |
108 | cpu_set_t cpu_set; | 135 | struct rt_task param; |
136 | |||
137 | init_rt_task_param(¶m); | ||
138 | param.exec_cost = e_ns; | ||
139 | param.period = p_ns; | ||
109 | 140 | ||
110 | CPU_ZERO(&cpu_set); | 141 | return set_rt_task_param(gettid(), ¶m); |
111 | CPU_SET(target_cpu, &cpu_set); | ||
112 | return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); | ||
113 | } | 142 | } |
114 | 143 | ||
115 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 144 | int sporadic_partitioned(lt_t e_ns, lt_t p_ns, int partition) |
116 | int cpu, unsigned int priority, | ||
117 | task_class_t cls, | ||
118 | budget_policy_t budget_policy, | ||
119 | budget_signal_policy_t budget_signal_policy, | ||
120 | int set_cpu_set) | ||
121 | { | 145 | { |
122 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, | 146 | int ret; |
123 | cpu, priority, cls, budget_policy, budget_signal_policy, | 147 | struct rt_task param; |
124 | set_cpu_set); | 148 | |
149 | ret = be_migrate_to_partition(partition); | ||
150 | check("be_migrate_to_partition()"); | ||
151 | if (ret != 0) | ||
152 | return ret; | ||
153 | |||
154 | init_rt_task_param(¶m); | ||
155 | param.exec_cost = e_ns; | ||
156 | param.period = p_ns; | ||
157 | param.cpu = partition_to_cpu(partition); | ||
158 | |||
159 | return set_rt_task_param(gettid(), ¶m); | ||
125 | } | 160 | } |
126 | 161 | ||
127 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | 162 | int sporadic_clustered(lt_t e_ns, lt_t p_ns, int cluster, int cluster_size) |
128 | int cpu, unsigned int priority, | ||
129 | task_class_t cls, | ||
130 | budget_policy_t budget_policy, | ||
131 | budget_signal_policy_t budget_signal_policy, | ||
132 | int set_cpu_set) | ||
133 | { | 163 | { |
134 | struct rt_task param; | ||
135 | int ret; | 164 | int ret; |
165 | struct rt_task param; | ||
166 | |||
167 | ret = be_migrate_to_cluster(cluster, cluster_size); | ||
168 | check("be_migrate_to_cluster()"); | ||
169 | if (ret != 0) | ||
170 | return ret; | ||
171 | |||
172 | init_rt_task_param(¶m); | ||
173 | param.exec_cost = e_ns; | ||
174 | param.period = p_ns; | ||
175 | param.cpu = cluster_to_first_cpu(cluster, cluster_size); | ||
136 | 176 | ||
137 | /* Zero out first --- this is helpful when we add plugin-specific | ||
138 | * parameters during development. | ||
139 | */ | ||
140 | memset(¶m, 0, sizeof(param)); | ||
141 | |||
142 | param.exec_cost = e; | ||
143 | param.period = p; | ||
144 | param.relative_deadline = p; /* implicit deadline */ | ||
145 | param.cpu = cpu; | ||
146 | param.cls = cls; | ||
147 | param.phase = phase; | ||
148 | param.budget_policy = budget_policy; | ||
149 | param.budget_signal_policy = budget_signal_policy; | ||
150 | param.priority = priority; | ||
151 | |||
152 | if (set_cpu_set) { | ||
153 | ret = be_migrate_to(cpu); | ||
154 | check("migrate to cpu"); | ||
155 | } | ||
156 | return set_rt_task_param(gettid(), ¶m); | 177 | return set_rt_task_param(gettid(), ¶m); |
157 | } | 178 | } |
158 | 179 | ||