diff options
Diffstat (limited to 'bin/base_mt_task.c')
-rw-r--r-- | bin/base_mt_task.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/bin/base_mt_task.c b/bin/base_mt_task.c index 802ef0b..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,9 +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 REL_DEADLINE 100 | 26 | #define RELATIVE_DEADLINE 100 |
26 | #define EXEC_COST 10 | 27 | #define EXEC_COST 10 |
28 | |||
29 | #define NS_PER_MS 1e6 | ||
27 | 30 | ||
28 | /* Let's create 10 threads in the example, | 31 | /* Let's create 10 threads in the example, |
29 | * for a total utilization of 1. | 32 | * for a total utilization of 1. |
@@ -123,6 +126,15 @@ void* rt_thread(void *tcontext) | |||
123 | { | 126 | { |
124 | int do_exit; | 127 | int do_exit; |
125 | 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(¶m, 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; | ||
126 | 138 | ||
127 | /* Make presence visible. */ | 139 | /* Make presence visible. */ |
128 | printf("RT Thread %d active.\n", ctx->id); | 140 | printf("RT Thread %d active.\n", ctx->id); |
@@ -131,7 +143,16 @@ void* rt_thread(void *tcontext) | |||
131 | * 1) Initialize real-time settings. | 143 | * 1) Initialize real-time settings. |
132 | */ | 144 | */ |
133 | CALL( init_rt_thread() ); | 145 | CALL( init_rt_thread() ); |
134 | CALL( sporadic_global(EXEC_COST, PERIOD, REL_DEADLINE) ); | 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(), ¶m) ); | ||
135 | 156 | ||
136 | /***** | 157 | /***** |
137 | * 2) Transition to real-time mode. | 158 | * 2) Transition to real-time mode. |