diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-09-07 23:22:38 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-09-07 23:24:15 -0400 |
commit | 4829f4175482e0a4ad8f282dd0441904c33e2f97 (patch) | |
tree | 1ea66f39beaa1f1fcad08763eebc90537a403b5f /src | |
parent | 12587122ff78adffa2e8bcb571962d8f19365fb9 (diff) |
Added signal-related comments. Made g++ friendly.prop/litmus-signals
Diffstat (limited to 'src')
-rw-r--r-- | src/litmus.c | 2 | ||||
-rw-r--r-- | src/signal.c | 28 | ||||
-rw-r--r-- | src/task.c | 4 |
3 files changed, 10 insertions, 24 deletions
diff --git a/src/litmus.c b/src/litmus.c index aaaeee3..0b7c561 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -26,7 +26,7 @@ task_class_t str2class(const char* str) | |||
26 | else if (!strcmp(str, "be")) | 26 | else if (!strcmp(str, "be")) |
27 | return RT_CLASS_BEST_EFFORT; | 27 | return RT_CLASS_BEST_EFFORT; |
28 | else | 28 | else |
29 | return -1; | 29 | return (task_class_t)(-1); |
30 | } | 30 | } |
31 | 31 | ||
32 | #define NS_PER_MS 1000000 | 32 | #define NS_PER_MS 1000000 |
diff --git a/src/signal.c b/src/signal.c index a98ed78..bfe18b9 100644 --- a/src/signal.c +++ b/src/signal.c | |||
@@ -4,26 +4,13 @@ | |||
4 | #include "litmus.h" | 4 | #include "litmus.h" |
5 | #include "internal.h" | 5 | #include "internal.h" |
6 | 6 | ||
7 | /* setjmp calls are stored on a singlely link list, | ||
8 | * one stack per thread. | ||
9 | */ | ||
7 | static __thread litmus_sigjmp_t *g_sigjmp_tail = 0; | 10 | static __thread litmus_sigjmp_t *g_sigjmp_tail = 0; |
8 | 11 | ||
9 | void throw_litmus_signal(int signum) | ||
10 | { | ||
11 | litmus_sigjmp_t *lit_env; | ||
12 | |||
13 | printf("WE GET SIGNAL!\n"); | ||
14 | lit_env = pop_sigjmp(); | ||
15 | if (lit_env) { | ||
16 | printf("received signal %d!\n", signum); | ||
17 | siglongjmp(lit_env->env, signum); | ||
18 | } | ||
19 | else { | ||
20 | /* silently ignore the signal. */ | ||
21 | } | ||
22 | } | ||
23 | |||
24 | void push_sigjmp(litmus_sigjmp_t *buf) | 12 | void push_sigjmp(litmus_sigjmp_t *buf) |
25 | { | 13 | { |
26 | printf("push\n"); | ||
27 | buf->prev = g_sigjmp_tail; | 14 | buf->prev = g_sigjmp_tail; |
28 | g_sigjmp_tail = buf; | 15 | g_sigjmp_tail = buf; |
29 | } | 16 | } |
@@ -31,7 +18,6 @@ void push_sigjmp(litmus_sigjmp_t *buf) | |||
31 | litmus_sigjmp_t* pop_sigjmp(void) | 18 | litmus_sigjmp_t* pop_sigjmp(void) |
32 | { | 19 | { |
33 | litmus_sigjmp_t* ret; | 20 | litmus_sigjmp_t* ret; |
34 | printf("pop\n"); | ||
35 | ret = g_sigjmp_tail; | 21 | ret = g_sigjmp_tail; |
36 | g_sigjmp_tail = (ret) ? ret->prev : NULL; | 22 | g_sigjmp_tail = (ret) ? ret->prev : NULL; |
37 | return ret; | 23 | return ret; |
@@ -46,7 +32,7 @@ static void reg_litmus_signals(unsigned long litmus_sig_mask, | |||
46 | ret = sigaction(SIG_BUDGET, pAction, NULL); | 32 | ret = sigaction(SIG_BUDGET, pAction, NULL); |
47 | check("SIG_BUDGET"); | 33 | check("SIG_BUDGET"); |
48 | } | 34 | } |
49 | /* more ... */ | 35 | /* more signals ... */ |
50 | } | 36 | } |
51 | 37 | ||
52 | void ignore_litmus_signals(unsigned long litmus_sig_mask) | 38 | void ignore_litmus_signals(unsigned long litmus_sig_mask) |
@@ -84,7 +70,7 @@ void block_litmus_signals(unsigned long litmus_sig_mask) | |||
84 | if (litmus_sig_mask | SIG_BUDGET_MASK) { | 70 | if (litmus_sig_mask | SIG_BUDGET_MASK) { |
85 | sigaddset(&sigs, SIG_BUDGET); | 71 | sigaddset(&sigs, SIG_BUDGET); |
86 | } | 72 | } |
87 | /* more ... */ | 73 | /* more signals ... */ |
88 | 74 | ||
89 | ret = sigprocmask(SIG_BLOCK, &sigs, NULL); | 75 | ret = sigprocmask(SIG_BLOCK, &sigs, NULL); |
90 | check("SIG_BLOCK litmus signals"); | 76 | check("SIG_BLOCK litmus signals"); |
@@ -108,11 +94,11 @@ void unblock_litmus_signals(unsigned long litmus_sig_mask) | |||
108 | 94 | ||
109 | void longjmp_on_litmus_signal(int signum) | 95 | void longjmp_on_litmus_signal(int signum) |
110 | { | 96 | { |
97 | /* We get signal! Main screen turn on! */ | ||
111 | litmus_sigjmp_t *lit_env; | 98 | litmus_sigjmp_t *lit_env; |
112 | printf("WE GET SIGNAL!\n"); | ||
113 | lit_env = pop_sigjmp(); | 99 | lit_env = pop_sigjmp(); |
114 | if (lit_env) { | 100 | if (lit_env) { |
115 | printf("received signal %d\n", signum); | 101 | /* What you say?! */ |
116 | siglongjmp(lit_env->env, signum); /* restores signal mask */ | 102 | siglongjmp(lit_env->env, signum); /* restores signal mask */ |
117 | } | 103 | } |
118 | else { | 104 | else { |
@@ -41,13 +41,13 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup, | |||
41 | } | 41 | } |
42 | 42 | ||
43 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, | 43 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period, |
44 | task_class_t class) | 44 | task_class_t rt_class) |
45 | { | 45 | { |
46 | struct rt_task params; | 46 | struct rt_task params; |
47 | params.cpu = cpu; | 47 | params.cpu = cpu; |
48 | params.period = period; | 48 | params.period = period; |
49 | params.exec_cost = wcet; | 49 | params.exec_cost = wcet; |
50 | params.cls = class; | 50 | params.cls = rt_class; |
51 | params.phase = 0; | 51 | params.phase = 0; |
52 | /* enforce budget for tasks that might not use sleep_next_period() */ | 52 | /* enforce budget for tasks that might not use sleep_next_period() */ |
53 | params.budget_policy = QUANTUM_ENFORCEMENT; | 53 | params.budget_policy = QUANTUM_ENFORCEMENT; |