aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-07-16 20:28:56 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2012-08-01 02:46:21 -0400
commitc84c35511dcc32262e12b8a4e99b4e678a433371 (patch)
treebe8deabc38d59dd1d077a8dd4c65c89ba1fdfecc
parent8afa727c28064c7672f656b889d8049b49370139 (diff)
API Update: Support arbitrary deadlines.
Updated APIs to support arbitrary deadlines. Added macros for implicit deadlines. Note: Had to tweak Makefile to support gcc version >= 4.6 (moved -lrt to the end of the link command).
-rw-r--r--Makefile2
-rw-r--r--bin/base_mt_task.c28
-rw-r--r--bin/base_task.c31
-rw-r--r--src/litmus.c1
-rw-r--r--tests/core_api.c3
5 files changed, 53 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 2109a45..391dc65 100644
--- a/Makefile
+++ b/Makefile
@@ -221,7 +221,7 @@ lib-measure_syscall = -lm
221 221
222.SECONDEXPANSION: 222.SECONDEXPANSION:
223${rt-apps}: $${obj-$$@} liblitmus.a 223${rt-apps}: $${obj-$$@} liblitmus.a
224 $(CC) -o $@ $(LDFLAGS) ${ldf-$@} $(filter-out liblitmus.a,$+) $(LOADLIBS) $(LDLIBS) ${lib-$@} ${liblitmus-flags} 224 $(CC) -o $@ $(LDFLAGS) ${ldf-$@} $(filter-out liblitmus.a,$+) $(LOADLIBS) $(LDLIBS) ${liblitmus-flags} ${lib-$@}
225 225
226# ############################################################################## 226# ##############################################################################
227# Dependency resolution. 227# Dependency resolution.
diff --git a/bin/base_mt_task.c b/bin/base_mt_task.c
index 19afb28..78446e3 100644
--- a/bin/base_mt_task.c
+++ b/bin/base_mt_task.c
@@ -11,6 +11,7 @@
11 11
12#include <stdio.h> 12#include <stdio.h>
13#include <stdlib.h> 13#include <stdlib.h>
14#include <string.h>
14 15
15/* Include gettid() */ 16/* Include gettid() */
16#include <sys/types.h> 17#include <sys/types.h>
@@ -21,8 +22,11 @@
21/* Include the LITMUS^RT API.*/ 22/* Include the LITMUS^RT API.*/
22#include "litmus.h" 23#include "litmus.h"
23 24
24#define PERIOD 100 25#define PERIOD 100
25#define EXEC_COST 10 26#define RELATIVE_DEADLINE 100
27#define EXEC_COST 10
28
29#define NS_PER_MS 1e6
26 30
27/* Let's create 10 threads in the example, 31/* Let's create 10 threads in the example,
28 * for a total utilization of 1. 32 * for a total utilization of 1.
@@ -122,6 +126,15 @@ void* rt_thread(void *tcontext)
122{ 126{
123 int do_exit; 127 int do_exit;
124 struct thread_context *ctx = (struct thread_context *) tcontext; 128 struct thread_context *ctx = (struct thread_context *) tcontext;
129 struct rt_task param;
130
131 /* Set up task parameters */
132 memset(&param, 0, sizeof(param));
133 param.exec_cost = EXEC_COST * NS_PER_MS;
134 param.period = PERIOD * NS_PER_MS;
135 param.relative_deadline = RELATIVE_DEADLINE * NS_PER_MS;
136 param.cls = RT_CLASS_SOFT;
137 param.budget_policy = NO_ENFORCEMENT;
125 138
126 /* Make presence visible. */ 139 /* Make presence visible. */
127 printf("RT Thread %d active.\n", ctx->id); 140 printf("RT Thread %d active.\n", ctx->id);
@@ -130,7 +143,16 @@ void* rt_thread(void *tcontext)
130 * 1) Initialize real-time settings. 143 * 1) Initialize real-time settings.
131 */ 144 */
132 CALL( init_rt_thread() ); 145 CALL( init_rt_thread() );
133 CALL( sporadic_global(EXEC_COST, PERIOD) ); 146
147 /* To specify a partition, do
148 *
149 * param.cpu = CPU;
150 * be_migrate_to(CPU);
151 *
152 * where CPU ranges from 0 to "Number of CPUs" - 1 before calling
153 * set_rt_task_param().
154 */
155 CALL( set_rt_task_param(gettid(), &param) );
134 156
135 /***** 157 /*****
136 * 2) Transition to real-time mode. 158 * 2) Transition to real-time mode.
diff --git a/bin/base_task.c b/bin/base_task.c
index c50990b..8baf3c8 100644
--- a/bin/base_task.c
+++ b/bin/base_task.c
@@ -12,6 +12,7 @@
12 */ 12 */
13#include <stdio.h> 13#include <stdio.h>
14#include <stdlib.h> 14#include <stdlib.h>
15#include <string.h>
15 16
16/* Second, we include the LITMUS^RT user space library header. 17/* Second, we include the LITMUS^RT user space library header.
17 * This header, part of liblitmus, provides the user space API of 18 * This header, part of liblitmus, provides the user space API of
@@ -22,9 +23,14 @@
22/* Next, we define period and execution cost to be constant. 23/* Next, we define period and execution cost to be constant.
23 * These are only constants for convenience in this example, they can be 24 * These are only constants for convenience in this example, they can be
24 * determined at run time, e.g., from command line parameters. 25 * determined at run time, e.g., from command line parameters.
26 *
27 * These are in milliseconds.
25 */ 28 */
26#define PERIOD 100 29#define PERIOD 100
27#define EXEC_COST 10 30#define RELATIVE_DEADLINE 100
31#define EXEC_COST 10
32
33#define NS_PER_MS 1e6
28 34
29/* Catch errors. 35/* Catch errors.
30 */ 36 */
@@ -60,6 +66,15 @@ int job(void);
60int main(int argc, char** argv) 66int main(int argc, char** argv)
61{ 67{
62 int do_exit; 68 int do_exit;
69 struct rt_task param;
70
71 /* Setup task parameters */
72 memset(&param, 0, sizeof(param));
73 param.exec_cost = EXEC_COST * NS_PER_MS;
74 param.period = PERIOD * NS_PER_MS;
75 param.relative_deadline = RELATIVE_DEADLINE * NS_PER_MS;
76 param.cls = RT_CLASS_SOFT;
77 param.budget_policy = NO_ENFORCEMENT;
63 78
64 /* The task is in background mode upon startup. */ 79 /* The task is in background mode upon startup. */
65 80
@@ -85,16 +100,16 @@ int main(int argc, char** argv)
85 * to the first partition (since partitioning is performed offline). 100 * to the first partition (since partitioning is performed offline).
86 */ 101 */
87 CALL( init_litmus() ); 102 CALL( init_litmus() );
88 CALL( sporadic_global(EXEC_COST, PERIOD) );
89 103
90 /* To specify a partition, use sporadic_partitioned(). 104 /* To specify a partition, do
91 * Example:
92 * 105 *
93 * sporadic_partitioned(EXEC_COST, PERIOD, CPU); 106 * param.cpu = CPU;
107 * be_migrate_to(CPU);
94 * 108 *
95 * where CPU ranges from 0 to "Number of CPUs" - 1. 109 * where CPU ranges from 0 to "Number of CPUs" - 1 before calling
110 * set_rt_task_param().
96 */ 111 */
97 112 CALL( set_rt_task_param(gettid(), &param) );
98 113
99 114
100 /***** 115 /*****
diff --git a/src/litmus.c b/src/litmus.c
index 33937c8..b32254b 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -105,6 +105,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase,
105 105
106 param.exec_cost = e; 106 param.exec_cost = e;
107 param.period = p; 107 param.period = p;
108 param.relative_deadline = p; /* implicit deadline */
108 param.cpu = cpu; 109 param.cpu = cpu;
109 param.cls = cls; 110 param.cls = cls;
110 param.phase = phase; 111 param.phase = phase;
diff --git a/tests/core_api.c b/tests/core_api.c
index 533fb8e..c5bbb5a 100644
--- a/tests/core_api.c
+++ b/tests/core_api.c
@@ -20,6 +20,7 @@ TESTCASE(set_rt_task_param_invalid_params, ALL,
20 struct rt_task params; 20 struct rt_task params;
21 params.cpu = 0; 21 params.cpu = 0;
22 params.period = 100; 22 params.period = 100;
23 params.relative_deadline = params.period;
23 params.phase = 0; 24 params.phase = 0;
24 params.priority = LITMUS_LOWEST_PRIORITY; 25 params.priority = LITMUS_LOWEST_PRIORITY;
25 params.cls = RT_CLASS_HARD; 26 params.cls = RT_CLASS_HARD;
@@ -50,6 +51,7 @@ TESTCASE(reject_bad_priorities, P_FP,
50 params.cpu = 0; 51 params.cpu = 0;
51 params.exec_cost = 10; 52 params.exec_cost = 10;
52 params.period = 100; 53 params.period = 100;
54 params.relative_deadline = params.period;
53 params.phase = 0; 55 params.phase = 0;
54 params.cls = RT_CLASS_HARD; 56 params.cls = RT_CLASS_HARD;
55 params.budget_policy = NO_ENFORCEMENT; 57 params.budget_policy = NO_ENFORCEMENT;
@@ -75,6 +77,7 @@ TESTCASE(accept_valid_priorities, P_FP,
75 params.cpu = 0; 77 params.cpu = 0;
76 params.exec_cost = 10; 78 params.exec_cost = 10;
77 params.period = 100; 79 params.period = 100;
80 params.relative_deadline = params.period;
78 params.phase = 0; 81 params.phase = 0;
79 params.cls = RT_CLASS_HARD; 82 params.cls = RT_CLASS_HARD;
80 params.budget_policy = NO_ENFORCEMENT; 83 params.budget_policy = NO_ENFORCEMENT;