aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clocks.c23
-rw-r--r--src/kernel_iface.c3
-rw-r--r--src/litmus.c2
-rw-r--r--src/syscalls.c29
4 files changed, 36 insertions, 21 deletions
diff --git a/src/clocks.c b/src/clocks.c
new file mode 100644
index 0000000..fcb94e5
--- /dev/null
+++ b/src/clocks.c
@@ -0,0 +1,23 @@
1#include <stdio.h>
2
3#include <sys/time.h>
4#include <time.h>
5
6/* CPU time consumed so far in seconds */
7double cputime(void)
8{
9 struct timespec ts;
10 int err;
11 err = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
12 if (err != 0)
13 perror("clock_gettime");
14 return (ts.tv_sec + 1E-9 * ts.tv_nsec);
15}
16
17/* wall-clock time in seconds */
18double wctime(void)
19{
20 struct timeval tv;
21 gettimeofday(&tv, NULL);
22 return (tv.tv_sec + 1E-6 * tv.tv_usec);
23}
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index afb6202..1426795 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -8,7 +8,6 @@
8 8
9#include "litmus.h" 9#include "litmus.h"
10#include "internal.h" 10#include "internal.h"
11#include "asm.h"
12 11
13#define LITMUS_CTRL_DEVICE "/dev/litmus/ctrl" 12#define LITMUS_CTRL_DEVICE "/dev/litmus/ctrl"
14#define CTRL_PAGES 1 13#define CTRL_PAGES 1
@@ -66,7 +65,7 @@ void exit_np(void)
66{ 65{
67 if (likely(ctrl_page != NULL) && --ctrl_page->np_flag == 0) { 66 if (likely(ctrl_page != NULL) && --ctrl_page->np_flag == 0) {
68 /* became preemptive, let's check for delayed preemptions */ 67 /* became preemptive, let's check for delayed preemptions */
69 barrier(); 68 __sync_synchronize();
70 if (ctrl_page->delayed_preemption) 69 if (ctrl_page->delayed_preemption)
71 sched_yield(); 70 sched_yield();
72 } 71 }
diff --git a/src/litmus.c b/src/litmus.c
index 84e844c..fe63bad 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -80,7 +80,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase,
80 param.period = p; 80 param.period = p;
81 param.cpu = cpu; 81 param.cpu = cpu;
82 param.cls = cls; 82 param.cls = cls;
83 param.crit = crit; 83 param.crit = crit;
84 param.phase = phase; 84 param.phase = phase;
85 param.budget_policy = budget_policy; 85 param.budget_policy = budget_policy;
86 86
diff --git a/src/syscalls.c b/src/syscalls.c
index 77a6277..d800141 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -1,13 +1,16 @@
1/* To get syscall() we need to define _GNU_SOURCE 1/* To get syscall() we need to define _GNU_SOURCE
2 * in modern glibc versions. 2 * in modern glibc versions.
3 */ 3 */
4
5/* imported from the kernel source tree */
6#include "asm/unistd.h"
7
8/* for syscall() */
4#include <unistd.h> 9#include <unistd.h>
5#include <linux/unistd.h>
6#include <sys/types.h>
7 10
8#include "litmus.h" 11//#include <sys/types.h>
9 12
10struct np_flag; 13#include "litmus.h"
11 14
12/* Syscall stub for setting RT mode and scheduling options */ 15/* Syscall stub for setting RT mode and scheduling options */
13 16
@@ -41,24 +44,14 @@ int od_close(int od)
41 return syscall(__NR_od_close, od); 44 return syscall(__NR_od_close, od);
42} 45}
43 46
44int fmlp_down(int od) 47int litmus_lock(int od)
45{
46 return syscall(__NR_fmlp_down, od);
47}
48
49int fmlp_up(int od)
50{
51 return syscall(__NR_fmlp_up, od);
52}
53
54int srp_down(int od)
55{ 48{
56 return syscall(__NR_srp_down, od); 49 return syscall(__NR_litmus_lock, od);
57} 50}
58 51
59int srp_up(int od) 52int litmus_unlock(int od)
60{ 53{
61 return syscall(__NR_srp_up, od); 54 return syscall(__NR_litmus_unlock, od);
62} 55}
63 56
64int get_job_no(unsigned int *job_no) 57int get_job_no(unsigned int *job_no)