diff options
-rw-r--r-- | bin/rtspin.c | 2 | ||||
-rw-r--r-- | include/litmus.h | 7 | ||||
-rw-r--r-- | src/litmus.c | 1 | ||||
-rw-r--r-- | tests/pcp.c | 54 |
4 files changed, 62 insertions, 2 deletions
diff --git a/bin/rtspin.c b/bin/rtspin.c index 1244073..87c178a 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
@@ -169,7 +169,7 @@ int main(int argc, char** argv) | |||
169 | lt_t wcet; | 169 | lt_t wcet; |
170 | lt_t period; | 170 | lt_t period; |
171 | double wcet_ms, period_ms; | 171 | double wcet_ms, period_ms; |
172 | unsigned int priority = 0; | 172 | unsigned int priority = LITMUS_MIN_PRIORITY; |
173 | int migrate = 0; | 173 | int migrate = 0; |
174 | int cpu = 0; | 174 | int cpu = 0; |
175 | int opt; | 175 | int opt; |
diff --git a/include/litmus.h b/include/litmus.h index 2357da9..232dcf5 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
@@ -58,6 +58,7 @@ typedef enum { | |||
58 | MPCP_SEM = 2, | 58 | MPCP_SEM = 2, |
59 | MPCP_VS_SEM = 3, | 59 | MPCP_VS_SEM = 3, |
60 | DPCP_SEM = 4, | 60 | DPCP_SEM = 4, |
61 | PCP_SEM = 5, | ||
61 | } obj_type_t; | 62 | } obj_type_t; |
62 | 63 | ||
63 | int lock_protocol_for_name(const char* name); | 64 | int lock_protocol_for_name(const char* name); |
@@ -106,7 +107,6 @@ task_class_t str2class(const char* str); | |||
106 | /* non-preemptive section support */ | 107 | /* non-preemptive section support */ |
107 | void enter_np(void); | 108 | void enter_np(void); |
108 | void exit_np(void); | 109 | void exit_np(void); |
109 | int exit_np_trace(void); | ||
110 | int requested_to_preempt(void); | 110 | int requested_to_preempt(void); |
111 | 111 | ||
112 | /* task system support */ | 112 | /* task system support */ |
@@ -138,6 +138,11 @@ static inline int open_srp_sem(int fd, int name) | |||
138 | return od_open(fd, SRP_SEM, name); | 138 | return od_open(fd, SRP_SEM, name); |
139 | } | 139 | } |
140 | 140 | ||
141 | static inline int open_pcp_sem(int fd, int name, int cpu) | ||
142 | { | ||
143 | return od_openx(fd, PCP_SEM, name, &cpu); | ||
144 | } | ||
145 | |||
141 | 146 | ||
142 | /* syscall overhead measuring */ | 147 | /* syscall overhead measuring */ |
143 | int null_call(cycles_t *timestamp); | 148 | int null_call(cycles_t *timestamp); |
diff --git a/src/litmus.c b/src/litmus.c index 9afe7a2..33937c8 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
@@ -22,6 +22,7 @@ static struct { | |||
22 | LP(MPCP_VS), | 22 | LP(MPCP_VS), |
23 | {MPCP_VS_SEM, "MPCP-VS"}, | 23 | {MPCP_VS_SEM, "MPCP-VS"}, |
24 | LP(DPCP), | 24 | LP(DPCP), |
25 | LP(PCP), | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | #define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0])) | 28 | #define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0])) |
diff --git a/tests/pcp.c b/tests/pcp.c new file mode 100644 index 0000000..a893da6 --- /dev/null +++ b/tests/pcp.c | |||
@@ -0,0 +1,54 @@ | |||
1 | #include <fcntl.h> | ||
2 | #include <unistd.h> | ||
3 | #include <stdio.h> | ||
4 | |||
5 | #include "tests.h" | ||
6 | #include "litmus.h" | ||
7 | |||
8 | |||
9 | TESTCASE(lock_pcp, P_FP, | ||
10 | "PCP acquisition and release") | ||
11 | { | ||
12 | int fd, od, cpu = 0; | ||
13 | |||
14 | SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); | ||
15 | |||
16 | SYSCALL( sporadic_partitioned(10, 100, cpu) ); | ||
17 | SYSCALL( task_mode(LITMUS_RT_TASK) ); | ||
18 | |||
19 | SYSCALL( od = open_pcp_sem(fd, 0, cpu) ); | ||
20 | |||
21 | SYSCALL( litmus_lock(od) ); | ||
22 | SYSCALL( litmus_unlock(od) ); | ||
23 | |||
24 | SYSCALL( litmus_lock(od) ); | ||
25 | SYSCALL( litmus_unlock(od) ); | ||
26 | |||
27 | SYSCALL( litmus_lock(od) ); | ||
28 | SYSCALL( litmus_unlock(od) ); | ||
29 | |||
30 | /* tasks may not unlock resources they don't own */ | ||
31 | SYSCALL_FAILS(EINVAL, litmus_unlock(od) ); | ||
32 | |||
33 | SYSCALL( od_close(od) ); | ||
34 | |||
35 | SYSCALL( close(fd) ); | ||
36 | |||
37 | SYSCALL( remove(".pcp_locks") ); | ||
38 | } | ||
39 | |||
40 | TESTCASE(not_lock_pcp_be, P_FP, | ||
41 | "don't let best-effort tasks lock PCP semaphores") | ||
42 | { | ||
43 | int fd, od; | ||
44 | |||
45 | SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); | ||
46 | |||
47 | /* BE task are not even allowed to open a PCP semaphore */ | ||
48 | SYSCALL_FAILS(EPERM, od = open_pcp_sem(fd, 0, 1) ); | ||
49 | |||
50 | SYSCALL( close(fd) ); | ||
51 | |||
52 | SYSCALL( remove(".pcp_locks") ); | ||
53 | |||
54 | } | ||