aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNamhoon Kim <namhoonk@cs.unc.edu>2016-04-30 17:45:01 -0400
committerNamhoon Kim <namhoonk@cs.unc.edu>2016-04-30 17:45:01 -0400
commit03e9cedc1879ffacc8f28a6fd38f0b73888b2826 (patch)
tree276bde2e69d557201bea4c9707cc03349a892511 /src
parentcc61f79e3a7f5b28c8731d0e041dd57cdcd812ca (diff)
RTSS16 microbench
Diffstat (limited to 'src')
-rw-r--r--src/color_shm.c40
-rw-r--r--src/kernel_iface.c56
-rw-r--r--src/syscalls.c4
3 files changed, 42 insertions, 58 deletions
diff --git a/src/color_shm.c b/src/color_shm.c
new file mode 100644
index 0000000..8531445
--- /dev/null
+++ b/src/color_shm.c
@@ -0,0 +1,40 @@
1#include <sys/mman.h>
2#include <stdio.h>
3
4#include "color_shm.h"
5
6void* color_mmap(size_t size, struct color_ioctl_cmd cmd, struct color_ioctl_offset offset)
7{
8 int ret, fd;
9 void *mem;
10
11 fd = open("/dev/litmus/color_shm", O_RDWR);
12 if (fd < 0) {
13 printf("Device open error.\n");
14 return NULL;
15 }
16
17 ret = ioctl(fd, SET_COLOR_SHM_CMD, &cmd);
18 if (ret < 0) {
19 printf("ioctl failed.\n");
20 return NULL;
21 }
22
23 ret = ioctl(fd, SET_COLOR_SHM_OFFSET, &offset);
24 if (ret < 0) {
25 printf("ioctl failed.\n");
26 return NULL;
27 }
28
29 size += offset.offset;
30 mem = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
31 if (mem == MAP_FAILED) {
32 printf("mmap failed.\n");
33 return MAP_FAILED;
34 }
35 close(fd);
36
37 mem += offset.offset;
38
39 return mem;
40} \ No newline at end of file
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index 49cef2a..a2c2104 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -140,62 +140,6 @@ 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
143void 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
155void 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
167void 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
180void 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
199/* init and return a ptr to the control page for 143/* init and return a ptr to the control page for
200 * preemption and migration overhead analysis 144 * preemption and migration overhead analysis
201 * 145 *
diff --git a/src/syscalls.c b/src/syscalls.c
index ab064ad..31fd62f 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -107,7 +107,7 @@ int set_page_color(int cpu)
107 return syscall(__NR_set_page_color, cpu); 107 return syscall(__NR_set_page_color, cpu);
108} 108}
109 109
110int test_call(unsigned int param) 110int run_bench(int type, int wss, cacheline_t *src, cacheline_t *dst, lt_t *ts)
111{ 111{
112 return syscall(__NR_test_call, param); 112 return syscall(__NR_run_test, type, wss, src, dst, ts);
113} 113}