aboutsummaryrefslogtreecommitdiffstats
path: root/bin
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 /bin
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).
Diffstat (limited to 'bin')
-rw-r--r--bin/base_mt_task.c28
-rw-r--r--bin/base_task.c31
2 files changed, 48 insertions, 11 deletions
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 /*****