diff options
-rw-r--r-- | include/litmus.h | 2 | ||||
-rw-r--r-- | src/task.c | 1 | ||||
-rw-r--r-- | tests/core_api.c | 60 |
3 files changed, 62 insertions, 1 deletions
diff --git a/include/litmus.h b/include/litmus.h index 1009805..ef3fef3 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -18,6 +18,8 @@ extern "C" { | |||
18 | 18 | ||
19 | #include "migration.h" | 19 | #include "migration.h" |
20 | 20 | ||
21 | #define SCHED_LITMUS 6 | ||
22 | |||
21 | void init_rt_task_param(struct rt_task* param); | 23 | void init_rt_task_param(struct rt_task* param); |
22 | int set_rt_task_param(pid_t pid, struct rt_task* param); | 24 | int set_rt_task_param(pid_t pid, struct rt_task* param); |
23 | int get_rt_task_param(pid_t pid, struct rt_task* param); | 25 | int get_rt_task_param(pid_t pid, struct rt_task* param); |
@@ -66,7 +66,6 @@ int create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, int cluster_size, | |||
66 | 66 | ||
67 | 67 | ||
68 | #define SCHED_NORMAL 0 | 68 | #define SCHED_NORMAL 0 |
69 | #define SCHED_LITMUS 6 | ||
70 | 69 | ||
71 | int task_mode(int mode) | 70 | int task_mode(int mode) |
72 | { | 71 | { |
diff --git a/tests/core_api.c b/tests/core_api.c index fc4deb9..42529ce 100644 --- a/tests/core_api.c +++ b/tests/core_api.c | |||
@@ -1,6 +1,8 @@ | |||
1 | #include <sys/wait.h> /* for waitpid() */ | 1 | #include <sys/wait.h> /* for waitpid() */ |
2 | #include <unistd.h> | 2 | #include <unistd.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | ||
5 | #include <sched.h> | ||
4 | 6 | ||
5 | #include "tests.h" | 7 | #include "tests.h" |
6 | #include "litmus.h" | 8 | #include "litmus.h" |
@@ -169,3 +171,61 @@ TESTCASE(ctrl_page_writable, ALL, | |||
169 | 171 | ||
170 | ctrl_page[32] = 0x12345678; | 172 | ctrl_page[32] = 0x12345678; |
171 | } | 173 | } |
174 | |||
175 | |||
176 | TESTCASE(suspended_admission, LITMUS, | ||
177 | "admission control handles suspended tasks correctly") | ||
178 | { | ||
179 | int child_rt, status; | ||
180 | struct sched_param param; | ||
181 | |||
182 | int pipefd[2], err, token = 0; | ||
183 | struct rt_task params; | ||
184 | |||
185 | SYSCALL( pipe(pipefd) ); | ||
186 | |||
187 | child_rt = FORK_TASK( | ||
188 | child_rt = gettid(); | ||
189 | /* make sure we are on the right CPU */ | ||
190 | be_migrate_to_cpu(0); | ||
191 | |||
192 | /* carry out a blocking read to suspend */ | ||
193 | err = read(pipefd[0], &token, sizeof(token)); | ||
194 | ASSERT(err = sizeof(token)); | ||
195 | ASSERT(token == 1234); | ||
196 | |||
197 | /* when we wake up, we should be a real-time task */ | ||
198 | ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS ); | ||
199 | |||
200 | SYSCALL( sleep_next_period() ); | ||
201 | SYSCALL( sleep_next_period() ); | ||
202 | |||
203 | exit(0); | ||
204 | ); | ||
205 | |||
206 | /* give child some time to suspend */ | ||
207 | SYSCALL( lt_sleep(ms2ns(100)) ); | ||
208 | |||
209 | init_rt_task_param(¶ms); | ||
210 | params.cpu = 0; | ||
211 | params.exec_cost = ms2ns(10); | ||
212 | params.period = ms2ns(100); | ||
213 | |||
214 | /* configure parameters of child */ | ||
215 | SYSCALL( set_rt_task_param(child_rt, ¶ms) ); | ||
216 | |||
217 | /* make it a real-time task */ | ||
218 | param.sched_priority = 0; | ||
219 | SYSCALL( sched_setscheduler(child_rt, SCHED_LITMUS, ¶m) ); | ||
220 | |||
221 | /* should be a real-time task now */ | ||
222 | ASSERT( sched_getscheduler(child_rt) == SCHED_LITMUS ); | ||
223 | |||
224 | /* unblock it */ | ||
225 | token = 1234; | ||
226 | ASSERT( write(pipefd[1], &token, sizeof(token)) == sizeof(token) ); | ||
227 | |||
228 | /* wait for child to exit */ | ||
229 | SYSCALL( waitpid(child_rt, &status, 0) ); | ||
230 | ASSERT( status == 0 ); | ||
231 | } | ||