aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-09-27 14:13:45 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2013-09-27 14:13:45 -0400
commit99b223a2c7185cabe274af63eec6dfcbec83c6db (patch)
tree54d62447ff81d49f9981d8a9b719b2d997180a8d
parent3ca122a0b342295de96c7aceab0c327f2410aaab (diff)
Add PGM support.
Adds routines for userspace tasks to use to communicate their state to the Litmus kernel.
-rw-r--r--include/litmus.h4
-rw-r--r--src/kernel_iface.c36
2 files changed, 40 insertions, 0 deletions
diff --git a/include/litmus.h b/include/litmus.h
index dc0d0bf..2817373 100644
--- a/include/litmus.h
+++ b/include/litmus.h
@@ -123,6 +123,10 @@ void enter_np(void);
123void exit_np(void); 123void exit_np(void);
124int requested_to_preempt(void); 124int requested_to_preempt(void);
125 125
126/* pgm support */
127void enter_pgm_wait(void);
128void exit_pgm_wait(void);
129
126/* task system support */ 130/* task system support */
127int wait_for_ts_release(void); 131int wait_for_ts_release(void);
128int release_ts(lt_t *delay); 132int release_ts(lt_t *delay);
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index ca874ff..3fe4f60 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -140,6 +140,42 @@ int requested_to_preempt(void)
140 return (likely(ctrl_page != NULL) && ctrl_page->sched.np.preempt); 140 return (likely(ctrl_page != NULL) && ctrl_page->sched.np.preempt);
141} 141}
142 142
143
144void enter_pgm_wait(void)
145{
146 if (likely(ctrl_page != NULL) || init_kernel_iface() == 0) {
147 if (!ctrl_page->pgm_waiting) {
148 ctrl_page->pgm_waiting = 1;
149 __sync_synchronize();
150 }
151 }
152 else {
153 fprintf(stderr, "enter_pgm_wait: control page not mapped!\n");
154 }
155}
156
157void exit_pgm_wait(void)
158{
159 if (likely(ctrl_page != NULL)) {
160 if (ctrl_page->pgm_waiting) {
161 ctrl_page->pgm_satisfied = 1;
162 __sync_synchronize();
163
164 /* re-eval priority. Should clear pgm_waiting and pgm_satisfied */
165 sched_yield();
166
167 if (ctrl_page->pgm_waiting || ctrl_page->pgm_satisfied) {
168 fprintf(stderr, "exit_pgm_wait: pgm flags not cleared! "
169 "waiting:%d satisfied:%d\n",
170 ctrl_page->pgm_waiting, ctrl_page->pgm_satisfied);
171 }
172 }
173 }
174 else {
175 fprintf(stderr, "exit_pgm_wait: control page not mapped!\n");
176 }
177}
178
143/* init and return a ptr to the control page for 179/* init and return a ptr to the control page for
144 * preemption and migration overhead analysis 180 * preemption and migration overhead analysis
145 * 181 *