aboutsummaryrefslogtreecommitdiffstats
path: root/bin/base_mt_task.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/base_mt_task.c')
-rw-r--r--bin/base_mt_task.c28
1 files changed, 25 insertions, 3 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.