diff options
author | Namhoon Kim <namhoonk@cs.unc.edu> | 2016-04-19 17:01:22 -0400 |
---|---|---|
committer | Namhoon Kim <namhoonk@cs.unc.edu> | 2016-04-19 17:01:22 -0400 |
commit | 800375b4a1569cf244596630b0c3fd1438f8d930 (patch) | |
tree | 0579e114cb150cbd7b428eb7739d3da3bf11f8f3 | |
parent | c00e89fc893092ef2efb74939efd2282dcbe6e92 (diff) |
add support for pgm
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | bin/mttest.c | 2 | ||||
-rw-r--r-- | include/color_shm.h | 6 | ||||
-rw-r--r-- | include/litmus.h | 12 | ||||
-rw-r--r-- | src/kernel_iface.c | 58 |
5 files changed, 74 insertions, 6 deletions
@@ -20,7 +20,7 @@ LITMUS_KERNEL ?= ../litmus-rt | |||
20 | 20 | ||
21 | # compiler flags | 21 | # compiler flags |
22 | flags-debug = -O0 -Wall -g -Wdeclaration-after-statement | 22 | flags-debug = -O0 -Wall -g -Wdeclaration-after-statement |
23 | flags-api = -D_XOPEN_SOURCE=600 -D_GNU_SOURCE | 23 | flags-api = -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -DCONFIG_PGMRT_SUPPORT |
24 | 24 | ||
25 | # architecture-specific flags | 25 | # architecture-specific flags |
26 | flags-i386 = -m32 | 26 | flags-i386 = -m32 |
diff --git a/bin/mttest.c b/bin/mttest.c index 3f1f655..7d573cc 100644 --- a/bin/mttest.c +++ b/bin/mttest.c | |||
@@ -77,7 +77,7 @@ int main(int argc, char** argv) | |||
77 | struct thread_context ctx[NUM_THREADS]; | 77 | struct thread_context ctx[NUM_THREADS]; |
78 | pthread_t task[NUM_THREADS]; | 78 | pthread_t task[NUM_THREADS]; |
79 | char *shm; | 79 | char *shm; |
80 | struct ioctl_cmd shm_info; | 80 | struct color_ioctl_cmd shm_info; |
81 | /* The task is in background mode upon startup. */ | 81 | /* The task is in background mode upon startup. */ |
82 | 82 | ||
83 | 83 | ||
diff --git a/include/color_shm.h b/include/color_shm.h index a95ffde..f6ad8a5 100644 --- a/include/color_shm.h +++ b/include/color_shm.h | |||
@@ -1,13 +1,13 @@ | |||
1 | #include <sys/ioctl.h> | 1 | #include <sys/ioctl.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | 3 | ||
4 | #define SHM_MAJOR 240 | 4 | #define SHM_MAJOR (240) |
5 | 5 | ||
6 | struct ioctl_cmd { | 6 | struct color_ioctl_cmd { |
7 | unsigned int color; | 7 | unsigned int color; |
8 | unsigned int bank; | 8 | unsigned int bank; |
9 | }; | 9 | }; |
10 | 10 | ||
11 | #define SET_COLOR_SHM_CMD \ | 11 | #define SET_COLOR_SHM_CMD \ |
12 | _IOW(SHM_MAJOR, 0x1, struct ioctl_cmd) | 12 | _IOW(SHM_MAJOR, 0x1, struct color_ioctl_cmd) |
13 | 13 | ||
diff --git a/include/litmus.h b/include/litmus.h index e96a4a6..aaa8d1c 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -148,6 +148,12 @@ int sporadic_clustered(lt_t e_ns, lt_t p_ns, int cluster); | |||
148 | /** Convert microseconds to nanoseconds | 148 | /** Convert microseconds to nanoseconds |
149 | * @param us Time units in microseconds */ | 149 | * @param us Time units in microseconds */ |
150 | #define us2ns(us) ((us)*1000LL) | 150 | #define us2ns(us) ((us)*1000LL) |
151 | #define ns2s(ns) ((ns)/1000000000LL) | ||
152 | #define ns2ms(ns) ((ns)/1000000LL) | ||
153 | #define ns2us(ns) ((ns)/1000LL) | ||
154 | #define us2ms(us) ((us)/1000LL) | ||
155 | #define us2s(us) ((us)/1000000LL) | ||
156 | #define ms2s(ms) ((ms)/1000LL) | ||
151 | 157 | ||
152 | /** | 158 | /** |
153 | * Locking protocols for allocated shared objects | 159 | * Locking protocols for allocated shared objects |
@@ -288,6 +294,12 @@ void exit_np(void); | |||
288 | */ | 294 | */ |
289 | int requested_to_preempt(void); | 295 | int requested_to_preempt(void); |
290 | 296 | ||
297 | /* pgm support */ | ||
298 | void enter_pgm_wait(void); | ||
299 | void exit_pgm_wait(void); | ||
300 | void enter_pgm_send(void); | ||
301 | void exit_pgm_send(void); | ||
302 | |||
291 | /***** Task System support *****/ | 303 | /***** Task System support *****/ |
292 | /** | 304 | /** |
293 | * Wait until task master releases all real-time tasks | 305 | * Wait until task master releases all real-time tasks |
diff --git a/src/kernel_iface.c b/src/kernel_iface.c index ca874ff..49cef2a 100644 --- a/src/kernel_iface.c +++ b/src/kernel_iface.c | |||
@@ -2,7 +2,7 @@ | |||
2 | #include <sys/fcntl.h> /* for O_RDWR */ | 2 | #include <sys/fcntl.h> /* for O_RDWR */ |
3 | #include <sys/unistd.h> | 3 | #include <sys/unistd.h> |
4 | #include <sched.h> /* for sched_yield() */ | 4 | #include <sched.h> /* for sched_yield() */ |
5 | 5 | #include <assert.h> | |
6 | 6 | ||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | 8 | ||
@@ -140,6 +140,62 @@ 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 | void enter_pgm_wait(void) | ||
144 | { | ||
145 | if (likely(ctrl_page != NULL) || init_kernel_iface() == 0) { | ||
146 | assert(!ctrl_page->pgm_waiting); | ||
147 | ctrl_page->pgm_waiting = 1; | ||
148 | __sync_synchronize(); | ||
149 | } | ||
150 | else { | ||
151 | fprintf(stderr, "enter_pgm_wait: control page not mapped!\n"); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | void exit_pgm_wait(void) | ||
156 | { | ||
157 | if (likely(ctrl_page != NULL)) { | ||
158 | assert(ctrl_page->pgm_waiting); | ||
159 | ctrl_page->pgm_waiting = 0; | ||
160 | __sync_synchronize(); | ||
161 | } | ||
162 | else { | ||
163 | fprintf(stderr, "exit_pgm_wait: control page not mapped!\n"); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | void enter_pgm_send(void) | ||
168 | { | ||
169 | if (likely(ctrl_page != NULL) || init_kernel_iface() == 0) { | ||
170 | assert(!ctrl_page->pgm_sending); | ||
171 | ctrl_page->pgm_sending = 1; /* we will become boosted if | ||
172 | anyone tries to preempt us. */ | ||
173 | __sync_synchronize(); | ||
174 | } | ||
175 | else { | ||
176 | fprintf(stderr, "enter_pgm_send: control page not mapped!\n"); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | void exit_pgm_send(void) | ||
181 | { | ||
182 | if (likely(ctrl_page != NULL)) { | ||
183 | assert(ctrl_page->pgm_sending); | ||
184 | |||
185 | ctrl_page->pgm_satisfied = 1; | ||
186 | __sync_synchronize(); | ||
187 | |||
188 | /* re-eval priority. Should clear pgm_sending and pgm_satisfied. */ | ||
189 | sched_yield(); | ||
190 | |||
191 | /* double check that Litmus is doing its job */ | ||
192 | assert(!ctrl_page->pgm_sending && !ctrl_page->pgm_satisfied); | ||
193 | } | ||
194 | else { | ||
195 | fprintf(stderr, "exit_pgm_send: control page not mapped!\n"); | ||
196 | } | ||
197 | } | ||
198 | |||
143 | /* init and return a ptr to the control page for | 199 | /* init and return a ptr to the control page for |
144 | * preemption and migration overhead analysis | 200 | * preemption and migration overhead analysis |
145 | * | 201 | * |