aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2013-06-08 14:05:29 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-06-08 18:13:43 -0400
commit4928cb8f9b596dde0f977bd8924a28dd38541f5f (patch)
tree9d56efc55b291a8fe353bf84e29b2fbbdbfa0343
parentd671324496bed1cd10fbdf425f049eae11efde14 (diff)
Add testcase for admission of suspended tasks
The kernel needs to be able to deal with tasks that do not make themselves a real-time task, but get configured by some other task instead.
-rw-r--r--include/litmus.h2
-rw-r--r--src/task.c1
-rw-r--r--tests/core_api.c60
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
21void init_rt_task_param(struct rt_task* param); 23void init_rt_task_param(struct rt_task* param);
22int set_rt_task_param(pid_t pid, struct rt_task* param); 24int set_rt_task_param(pid_t pid, struct rt_task* param);
23int get_rt_task_param(pid_t pid, struct rt_task* param); 25int get_rt_task_param(pid_t pid, struct rt_task* param);
diff --git a/src/task.c b/src/task.c
index 9121f0c..5f2fa26 100644
--- a/src/task.c
+++ b/src/task.c
@@ -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
71int task_mode(int mode) 70int 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
176TESTCASE(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(&params);
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, &params) );
216
217 /* make it a real-time task */
218 param.sched_priority = 0;
219 SYSCALL( sched_setscheduler(child_rt, SCHED_LITMUS, &param) );
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}