diff options
Diffstat (limited to 'bin/base_task.c')
-rw-r--r-- | bin/base_task.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/bin/base_task.c b/bin/base_task.c index b2408ac..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,10 +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 REL_DEADLINE 100 | 30 | #define RELATIVE_DEADLINE 100 |
28 | #define EXEC_COST 10 | 31 | #define EXEC_COST 10 |
32 | |||
33 | #define NS_PER_MS 1e6 | ||
29 | 34 | ||
30 | /* Catch errors. | 35 | /* Catch errors. |
31 | */ | 36 | */ |
@@ -61,6 +66,15 @@ int job(void); | |||
61 | int main(int argc, char** argv) | 66 | int main(int argc, char** argv) |
62 | { | 67 | { |
63 | int do_exit; | 68 | int do_exit; |
69 | struct rt_task param; | ||
70 | |||
71 | /* Setup task parameters */ | ||
72 | memset(¶m, 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; | ||
64 | 78 | ||
65 | /* The task is in background mode upon startup. */ | 79 | /* The task is in background mode upon startup. */ |
66 | 80 | ||
@@ -86,16 +100,16 @@ int main(int argc, char** argv) | |||
86 | * to the first partition (since partitioning is performed offline). | 100 | * to the first partition (since partitioning is performed offline). |
87 | */ | 101 | */ |
88 | CALL( init_litmus() ); | 102 | CALL( init_litmus() ); |
89 | CALL( sporadic_global(EXEC_COST, PERIOD, REL_DEADLINE) ); | ||
90 | 103 | ||
91 | /* To specify a partition, use sporadic_partitioned(). | 104 | /* To specify a partition, do |
92 | * Example: | ||
93 | * | 105 | * |
94 | * sporadic_partitioned(EXEC_COST, PERIOD, CPU); | 106 | * param.cpu = CPU; |
107 | * be_migrate_to(CPU); | ||
95 | * | 108 | * |
96 | * 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(). | ||
97 | */ | 111 | */ |
98 | 112 | CALL( set_rt_task_param(gettid(), ¶m) ); | |
99 | 113 | ||
100 | 114 | ||
101 | /***** | 115 | /***** |