aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2011-07-28 01:16:04 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2011-11-24 14:48:23 -0500
commit4d4ba58fca7753c1bbe56d43e7977f2a9601e772 (patch)
tree565aa066a95d207972801f0d9839df6433c3c376
parentecf0549adc8b86c9daeee9eb4cd186fdec2aa21b (diff)
Switch to new np-section protocol.
Everything is in one 32-bit word now.
-rw-r--r--include/internal.h5
-rw-r--r--include/litmus.h1
-rw-r--r--src/kernel_iface.c15
3 files changed, 18 insertions, 3 deletions
diff --git a/include/internal.h b/include/internal.h
index 07253b7..f30ce61 100644
--- a/include/internal.h
+++ b/include/internal.h
@@ -18,8 +18,13 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg,
18 } 18 }
19 19
20 20
21/* taken from the kernel */
22
21#define likely(x) __builtin_expect((x), 1) 23#define likely(x) __builtin_expect((x), 1)
22#define unlikely(x) __builtin_expect((x), 0) 24#define unlikely(x) __builtin_expect((x), 0)
23 25
26#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
27#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
28
24#endif 29#endif
25 30
diff --git a/include/litmus.h b/include/litmus.h
index 40ee124..4c85d28 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -96,6 +96,7 @@ task_class_t str2class(const char* str);
96/* non-preemptive section support */ 96/* non-preemptive section support */
97void enter_np(void); 97void enter_np(void);
98void exit_np(void); 98void exit_np(void);
99int requested_to_preempt(void);
99 100
100/* task system support */ 101/* task system support */
101int wait_for_ts_release(void); 102int wait_for_ts_release(void);
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index 1426795..33d56df 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -43,6 +43,8 @@ int init_kernel_iface(void)
43 int err = 0; 43 int err = 0;
44 long page_size = sysconf(_SC_PAGESIZE); 44 long page_size = sysconf(_SC_PAGESIZE);
45 45
46 BUILD_BUG_ON(sizeof(union np_flag) != sizeof(uint32_t));
47
46 err = map_file(LITMUS_CTRL_DEVICE, (void**) &ctrl_page, CTRL_PAGES * page_size); 48 err = map_file(LITMUS_CTRL_DEVICE, (void**) &ctrl_page, CTRL_PAGES * page_size);
47 if (err) { 49 if (err) {
48 fprintf(stderr, "%s: cannot open LITMUS^RT control page (%m)\n", 50 fprintf(stderr, "%s: cannot open LITMUS^RT control page (%m)\n",
@@ -55,7 +57,7 @@ int init_kernel_iface(void)
55void enter_np(void) 57void enter_np(void)
56{ 58{
57 if (likely(ctrl_page != NULL) || init_kernel_iface() == 0) 59 if (likely(ctrl_page != NULL) || init_kernel_iface() == 0)
58 ctrl_page->np_flag++; 60 ctrl_page->sched.np.flag++;
59 else 61 else
60 fprintf(stderr, "enter_np: control page not mapped!\n"); 62 fprintf(stderr, "enter_np: control page not mapped!\n");
61} 63}
@@ -63,14 +65,21 @@ void enter_np(void)
63 65
64void exit_np(void) 66void exit_np(void)
65{ 67{
66 if (likely(ctrl_page != NULL) && --ctrl_page->np_flag == 0) { 68 if (likely(ctrl_page != NULL) &&
69 ctrl_page->sched.np.flag &&
70 !(--ctrl_page->sched.np.flag)) {
67 /* became preemptive, let's check for delayed preemptions */ 71 /* became preemptive, let's check for delayed preemptions */
68 __sync_synchronize(); 72 __sync_synchronize();
69 if (ctrl_page->delayed_preemption) 73 if (ctrl_page->sched.np.preempt)
70 sched_yield(); 74 sched_yield();
71 } 75 }
72} 76}
73 77
78int requested_to_preempt(void)
79{
80 return (likely(ctrl_page != NULL) && ctrl_page->sched.np.preempt);
81}
82
74/* init and return a ptr to the control page for 83/* init and return a ptr to the control page for
75 * preemption and migration overhead analysis 84 * preemption and migration overhead analysis
76 * 85 *