aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Erickson <jerickso@cs.unc.edu>2013-01-28 22:28:29 -0500
committerJeremy Erickson <jerickso@cs.unc.edu>2013-01-28 22:28:29 -0500
commit6bb644a69dde49ffc8c3fb484a6a3bf81d21181c (patch)
tree133cbc52dd657efc7ead4c91f89ed5249998416f
parentf8ffc9dd7082a677c7d8027985981d8e319b0817 (diff)
Add support for measurement code from bbbdisswip-splitting-jerickso
-rw-r--r--bin/fmlp_test_task.c2
-rw-r--r--bin/rtspin.c2
-rw-r--r--include/litmus.h12
-rw-r--r--src/kernel_iface.c15
-rw-r--r--src/litmus.c42
5 files changed, 64 insertions, 9 deletions
diff --git a/bin/fmlp_test_task.c b/bin/fmlp_test_task.c
index 0ecd5cc..3500326 100644
--- a/bin/fmlp_test_task.c
+++ b/bin/fmlp_test_task.c
@@ -186,7 +186,7 @@ void* rt_thread(void *tcontext)
186 CALL( init_rt_thread() ); 186 CALL( init_rt_thread() );
187 187
188 ctx->semaphore = open_fmlp_sem(ctx->fd, 0); 188 ctx->semaphore = open_fmlp_sem(ctx->fd, 0);
189 CALL( sporadic_task_ns(ctx->exec, ctx->period, 0, ctx->split, 1, 189 CALL( sporadic_task_ns(ctx->exec, ctx->period, 0, ctx->split, 1, 0,
190 RT_CLASS_HARD, PRECISE_ENFORCEMENT, 1)); 190 RT_CLASS_HARD, PRECISE_ENFORCEMENT, 1));
191 191
192 192
diff --git a/bin/rtspin.c b/bin/rtspin.c
index 1d60524..4acde37 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -280,7 +280,7 @@ int main(int argc, char** argv)
280 bail_out("could not migrate to target partition"); 280 bail_out("could not migrate to target partition");
281 } 281 }
282 282
283 ret = sporadic_task_ns(wcet, period, 0, split, cpu, class, 283 ret = sporadic_task_ns(wcet, period, 0, split, cpu, 0, class,
284 want_enforcement ? PRECISE_ENFORCEMENT 284 want_enforcement ? PRECISE_ENFORCEMENT
285 : NO_ENFORCEMENT, 285 : NO_ENFORCEMENT,
286 migrate); 286 migrate);
diff --git a/include/litmus.h b/include/litmus.h
index 78fb4f4..a95287c 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -32,20 +32,20 @@ int get_rt_task_param(pid_t pid, struct rt_task* param);
32/* times are given in ms */ 32/* times are given in ms */
33int sporadic_task( 33int sporadic_task(
34 lt_t e, lt_t p, lt_t phase, int split, 34 lt_t e, lt_t p, lt_t phase, int split,
35 int partition, task_class_t cls, 35 int partition, unsigned int priority, task_class_t cls,
36 budget_policy_t budget_policy, int set_cpu_set); 36 budget_policy_t budget_policy, int set_cpu_set);
37 37
38/* times are given in ns */ 38/* times are given in ns */
39int sporadic_task_ns( 39int sporadic_task_ns(
40 lt_t e, lt_t p, lt_t phase, int split, 40 lt_t e, lt_t p, lt_t phase, int split,
41 int cpu, task_class_t cls, 41 int cpu, unsigned int priority, task_class_t cls,
42 budget_policy_t budget_policy, int set_cpu_set); 42 budget_policy_t budget_policy, int set_cpu_set);
43 43
44/* budget enforcement off by default in these macros */ 44/* budget enforcement off by default in these macros */
45#define sporadic_global(e, p) \ 45#define sporadic_global(e, p) \
46 sporadic_task(e, p, 0, 1, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0) 46 sporadic_task(e, p, 0, 1, 0, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 0)
47#define sporadic_partitioned(e, p, cpu) \ 47#define sporadic_partitioned(e, p, cpu) \
48 sporadic_task(e, p, 0, 1, cpu, RT_CLASS_SOFT, NO_ENFORCEMENT, 1) 48 sporadic_task(e, p, 0, 1, cpu, 0, RT_CLASS_SOFT, NO_ENFORCEMENT, 1)
49 49
50/* file descriptor attached shared objects support */ 50/* file descriptor attached shared objects support */
51typedef enum { 51typedef enum {
@@ -53,6 +53,9 @@ typedef enum {
53 SRP_SEM = 1, 53 SRP_SEM = 1,
54} obj_type_t; 54} obj_type_t;
55 55
56int lock_protocol_for_name(const char* name);
57const char* name_for_lock_protocol(int id);
58
56int od_openx(int fd, obj_type_t type, int obj_id, void* config); 59int od_openx(int fd, obj_type_t type, int obj_id, void* config);
57int od_close(int od); 60int od_close(int od);
58 61
@@ -97,6 +100,7 @@ task_class_t str2class(const char* str);
97/* non-preemptive section support */ 100/* non-preemptive section support */
98void enter_np(void); 101void enter_np(void);
99void exit_np(void); 102void exit_np(void);
103int exit_np_trace(void);
100int requested_to_preempt(void); 104int requested_to_preempt(void);
101 105
102/* task system support */ 106/* task system support */
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index 33d56df..4ded334 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -75,6 +75,21 @@ void exit_np(void)
75 } 75 }
76} 76}
77 77
78int exit_np_trace(void)
79{
80 if (likely(ctrl_page != NULL) &&
81 ctrl_page->sched.np.flag &&
82 !(--ctrl_page->sched.np.flag)) {
83 __sync_synchronize();
84 if (ctrl_page->sched.np.preempt) {
85 ctrl_page->ts_syscall_start = (uint64_t) get_cycles();
86 sched_yield();
87 return 1;
88 }
89 }
90 return 0;
91}
92
78int requested_to_preempt(void) 93int requested_to_preempt(void)
79{ 94{
80 return (likely(ctrl_page != NULL) && ctrl_page->sched.np.preempt); 95 return (likely(ctrl_page != NULL) && ctrl_page->sched.np.preempt);
diff --git a/src/litmus.c b/src/litmus.c
index bb08e87..96ecebc 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -10,6 +10,40 @@
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
15static struct {
16 int id;
17 const char* name;
18} protocol[] = {
19 LP(FMLP),
20 LP(SRP)
21};
22
23#define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0]))
24
25int lock_protocol_for_name(const char* name)
26{
27 int i;
28
29 for (i = 0; i < NUM_PROTOS; i++)
30 if (strcmp(name, protocol[i].name) == 0)
31 return protocol[i].id;
32
33 return -1;
34}
35
36const char* name_for_lock_protocol(int id)
37{
38 int i;
39
40 for (i = 0; i < NUM_PROTOS; i++)
41 if (protocol[i].id == id)
42 return protocol[i].name;
43
44 return "<UNKNOWN>";
45}
46
13void show_rt_param(struct rt_task* tp) 47void show_rt_param(struct rt_task* tp)
14{ 48{
15 printf("rt params:\n\t" 49 printf("rt params:\n\t"
@@ -42,15 +76,16 @@ int be_migrate_to(int target_cpu)
42} 76}
43 77
44int sporadic_task(lt_t e, lt_t p, lt_t phase, int split, 78int sporadic_task(lt_t e, lt_t p, lt_t phase, int split,
45 int cpu, task_class_t cls, 79 int cpu, unsigned int priority, task_class_t cls,
46 budget_policy_t budget_policy, int set_cpu_set) 80 budget_policy_t budget_policy, int set_cpu_set)
47{ 81{
48 return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS, 82 return sporadic_task_ns(e * NS_PER_MS, p * NS_PER_MS, phase * NS_PER_MS,
49 split, cpu, cls, budget_policy, set_cpu_set); 83 split, cpu, priority, cls, budget_policy,
84 set_cpu_set);
50} 85}
51 86
52int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, int split, 87int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, int split,
53 int cpu, task_class_t cls, 88 int cpu, unsigned int priority, task_class_t cls,
54 budget_policy_t budget_policy, int set_cpu_set) 89 budget_policy_t budget_policy, int set_cpu_set)
55{ 90{
56 struct rt_task param; 91 struct rt_task param;
@@ -65,6 +100,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase, int split,
65 param.period = p; 100 param.period = p;
66 param.split = split; 101 param.split = split;
67 param.cpu = cpu; 102 param.cpu = cpu;
103 param.priority = priority;
68 param.cls = cls; 104 param.cls = cls;
69 param.phase = phase; 105 param.phase = phase;
70 param.budget_policy = budget_policy; 106 param.budget_policy = budget_policy;