diff options
-rw-r--r-- | bin/rtspin.c | 10 | ||||
-rw-r--r-- | include/litmus.h | 19 | ||||
-rw-r--r-- | src/litmus.c | 50 | ||||
-rw-r--r-- | tests/locks.c | 8 |
4 files changed, 73 insertions, 14 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c index ae76941..1244073 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
@@ -161,7 +161,7 @@ static int job(double exec_time, double program_end) | |||
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | #define OPTSTR "p:c:wlveo:f:s:" | 164 | #define OPTSTR "p:c:wlveo:f:s:q:" |
165 | 165 | ||
166 | int main(int argc, char** argv) | 166 | int main(int argc, char** argv) |
167 | { | 167 | { |
@@ -169,6 +169,7 @@ int main(int argc, char** argv) | |||
169 | lt_t wcet; | 169 | lt_t wcet; |
170 | lt_t period; | 170 | lt_t period; |
171 | double wcet_ms, period_ms; | 171 | double wcet_ms, period_ms; |
172 | unsigned int priority = 0; | ||
172 | int migrate = 0; | 173 | int migrate = 0; |
173 | int cpu = 0; | 174 | int cpu = 0; |
174 | int opt; | 175 | int opt; |
@@ -194,6 +195,11 @@ int main(int argc, char** argv) | |||
194 | cpu = atoi(optarg); | 195 | cpu = atoi(optarg); |
195 | migrate = 1; | 196 | migrate = 1; |
196 | break; | 197 | break; |
198 | case 'q': | ||
199 | priority = atoi(optarg); | ||
200 | if (priority == 0 || priority > LITMUS_MAX_PRIORITY) | ||
201 | usage("Invalid priority."); | ||
202 | break; | ||
197 | case 'c': | 203 | case 'c': |
198 | class = str2class(optarg); | 204 | class = str2class(optarg); |
199 | if (class == -1) | 205 | if (class == -1) |
@@ -274,7 +280,7 @@ int main(int argc, char** argv) | |||
274 | bail_out("could not migrate to target partition"); | 280 | bail_out("could not migrate to target partition"); |
275 | } | 281 | } |
276 | 282 | ||
277 | ret = sporadic_task_ns(wcet, period, 0, cpu, class, | 283 | ret = sporadic_task_ns(wcet, period, 0, cpu, priority, class, |
278 | want_enforcement ? PRECISE_ENFORCEMENT | 284 | want_enforcement ? PRECISE_ENFORCEMENT |
279 | : NO_ENFORCEMENT, | 285 | : NO_ENFORCEMENT, |
280 | migrate); | 286 | migrate); |
diff --git a/include/litmus.h b/include/litmus.h index 4c85d28..2357da9 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -32,27 +32,37 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); | |||
32 | /* times are given in ms */ | 32 | /* times are given in ms */ |
33 | int sporadic_task( | 33 | int sporadic_task( |
34 | lt_t e, lt_t p, lt_t phase, | 34 | lt_t e, lt_t p, lt_t phase, |
35 | int partition, task_class_t cls, | 35 | int partition, unsigned int priority, |
36 | task_class_t cls, | ||
36 | budget_policy_t budget_policy, int set_cpu_set); | 37 | budget_policy_t budget_policy, int set_cpu_set); |
37 | 38 | ||
38 | /* times are given in ns */ | 39 | /* times are given in ns */ |
39 | int sporadic_task_ns( | 40 | int sporadic_task_ns( |
40 | lt_t e, lt_t p, lt_t phase, | 41 | lt_t e, lt_t p, lt_t phase, |
41 | int cpu, task_class_t cls, | 42 | int cpu, unsigned int priority, |
43 | task_class_t cls, | ||
42 | budget_policy_t budget_policy, int set_cpu_set); | 44 | budget_policy_t budget_policy, int set_cpu_set); |
43 | 45 | ||
44 | /* budget enforcement off by default in these macros */ | 46 | /* budget enforcement off by default in these macros */ |
45 | #define sporadic_global(e, p) \ | 47 | #define sporadic_global(e, p) \ |
46 | sporadic_task(e, p, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) | 48 | sporadic_task(e, p, 0, 0, LITMUS_MAX_PRIORITY-1, \ |
49 | RT_CLASS_SOFT, NO_ENFORCEMENT, 0) | ||
47 | #define sporadic_partitioned(e, p, cpu) \ | 50 | #define sporadic_partitioned(e, p, cpu) \ |
48 | sporadic_task(e, p, 0, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) | 51 | sporadic_task(e, p, 0, cpu, LITMUS_MAX_PRIORITY-1, \ |
52 | RT_CLASS_SOFT, NO_ENFORCEMENT, 1) | ||
49 | 53 | ||
50 | /* file descriptor attached shared objects support */ | 54 | /* file descriptor attached shared objects support */ |
51 | typedef enum { | 55 | typedef enum { |
52 | FMLP_SEM = 0, | 56 | FMLP_SEM = 0, |
53 | SRP_SEM = 1, | 57 | SRP_SEM = 1, |
58 | MPCP_SEM = 2, | ||
59 | MPCP_VS_SEM = 3, | ||
60 | DPCP_SEM = 4, | ||
54 | } obj_type_t; | 61 | } obj_type_t; |
55 | 62 | ||
63 | int lock_protocol_for_name(const char* name); | ||
64 | const char* name_for_lock_protocol(int id); | ||
65 | |||
56 | int od_openx(int fd, obj_type_t type, int obj_id, void* config); | 66 | int od_openx(int fd, obj_type_t type, int obj_id, void* config); |
57 | int od_close(int od); | 67 | int od_close(int od); |
58 | 68 | ||
@@ -96,6 +106,7 @@ task_class_t str2class(const char* str); | |||
96 | /* non-preemptive section support */ | 106 | /* non-preemptive section support */ |
97 | void enter_np(void); | 107 | void enter_np(void); |
98 | void exit_np(void); | 108 | void exit_np(void); |
109 | int exit_np_trace(void); | ||
99 | int requested_to_preempt(void); | 110 | int requested_to_preempt(void); |
100 | 111 | ||
101 | /* task system support */ | 112 | /* task system support */ |
diff --git a/src/litmus.c b/src/litmus.c index d3cc6bb..9afe7a2 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -10,6 +10,45 @@ | |||
10 | #include "litmus.h" | 10 | #include "litmus.h" |
11 | #include "internal.h" | 11 | #include "internal.h" |
12 | 12 | ||
13 | #define LP(name) {name ## _SEM, #name} | ||
14 | |||
15 | static struct { | ||
16 | int id; | ||
17 | const char* name; | ||
18 | } protocol[] = { | ||
19 | LP(FMLP), | ||
20 | LP(SRP), | ||
21 | LP(MPCP), | ||
22 | LP(MPCP_VS), | ||
23 | {MPCP_VS_SEM, "MPCP-VS"}, | ||
24 | LP(DPCP), | ||
25 | }; | ||
26 | |||
27 | #define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0])) | ||
28 | |||
29 | int lock_protocol_for_name(const char* name) | ||
30 | { | ||
31 | int i; | ||
32 | |||
33 | for (i = 0; i < NUM_PROTOS; i++) | ||
34 | if (strcmp(name, protocol[i].name) == 0) | ||
35 | return protocol[i].id; | ||
36 | |||
37 | return -1; | ||
38 | } | ||
39 | |||
40 | const char* name_for_lock_protocol(int id) | ||
41 | { | ||
42 | int i; | ||
43 | |||
44 | for (i = 0; i < NUM_PROTOS; i++) | ||
45 | if (protocol[i].id == id) | ||
46 | return protocol[i].name; | ||
47 | |||
48 | return "<UNKNOWN>"; | ||
49 | } | ||
50 | |||
51 | |||
13 | void show_rt_param(struct rt_task* tp) | 52 | void show_rt_param(struct rt_task* tp) |
14 | { | 53 | { |
15 | printf("rt params:\n\t" | 54 | printf("rt params:\n\t" |
@@ -42,16 +81,18 @@ int be_migrate_to(int target_cpu) | |||
42 | } | 81 | } |
43 | 82 | ||
44 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 83 | int sporadic_task(lt_t e, lt_t p, lt_t phase, |
45 | int cpu, task_class_t cls, | 84 | int cpu, unsigned int priority, |
85 | task_class_t cls, | ||
46 | budget_policy_t budget_policy, int set_cpu_set) | 86 | budget_policy_t budget_policy, int set_cpu_set) |
47 | { | 87 | { |
48 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, | 88 | return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, |
49 | cpu, cls, budget_policy, set_cpu_set); | 89 | cpu, priority, cls, budget_policy, set_cpu_set); |
50 | } | 90 | } |
51 | 91 | ||
52 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | 92 | int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, |
53 | int cpu, task_class_t cls, | 93 | int cpu, unsigned int priority, |
54 | budget_policy_t budget_policy, int set_cpu_set) | 94 | task_class_t cls, |
95 | budget_policy_t budget_policy, int set_cpu_set) | ||
55 | { | 96 | { |
56 | struct rt_task param; | 97 | struct rt_task param; |
57 | int ret; | 98 | int ret; |
@@ -67,6 +108,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, | |||
67 | param.cls = cls; | 108 | param.cls = cls; |
68 | param.phase = phase; | 109 | param.phase = phase; |
69 | param.budget_policy = budget_policy; | 110 | param.budget_policy = budget_policy; |
111 | param.priority = priority; | ||
70 | 112 | ||
71 | if (set_cpu_set) { | 113 | if (set_cpu_set) { |
72 | ret = be_migrate_to(cpu); | 114 | ret = be_migrate_to(cpu); |
diff --git a/tests/locks.c b/tests/locks.c index 65b932a..d7ebfe2 100644 --- a/tests/locks.c +++ b/tests/locks.c | |||
@@ -6,7 +6,7 @@ | |||
6 | #include "litmus.h" | 6 | #include "litmus.h" |
7 | 7 | ||
8 | 8 | ||
9 | TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF, | 9 | TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF | P_FP, |
10 | "don't let best-effort tasks lock FMLP semaphores") | 10 | "don't let best-effort tasks lock FMLP semaphores") |
11 | { | 11 | { |
12 | int fd, od; | 12 | int fd, od; |
@@ -29,7 +29,7 @@ TESTCASE(not_lock_fmlp_be, GSN_EDF | PSN_EDF, | |||
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | TESTCASE(not_lock_srp_be, PSN_EDF, | 32 | TESTCASE(not_lock_srp_be, PSN_EDF | P_FP, |
33 | "don't let best-effort tasks open SRP semaphores") | 33 | "don't let best-effort tasks open SRP semaphores") |
34 | { | 34 | { |
35 | int fd, od; | 35 | int fd, od; |
@@ -46,7 +46,7 @@ TESTCASE(not_lock_srp_be, PSN_EDF, | |||
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | TESTCASE(lock_srp, PSN_EDF, | 49 | TESTCASE(lock_srp, PSN_EDF | P_FP, |
50 | "SRP acquisition and release") | 50 | "SRP acquisition and release") |
51 | { | 51 | { |
52 | int fd, od; | 52 | int fd, od; |
@@ -78,7 +78,7 @@ TESTCASE(lock_srp, PSN_EDF, | |||
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | TESTCASE(lock_fmlp, PSN_EDF | GSN_EDF, | 81 | TESTCASE(lock_fmlp, PSN_EDF | GSN_EDF | P_FP, |
82 | "FMLP acquisition and release") | 82 | "FMLP acquisition and release") |
83 | { | 83 | { |
84 | int fd, od; | 84 | int fd, od; |