aboutsummaryrefslogtreecommitdiffstats
path: root/bin/base_task.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/base_task.c')
-rw-r--r--bin/base_task.c31
1 files changed, 23 insertions, 8 deletions
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 /*****