blob: e5bf1ea8329d9b7da0723082a8caf35d561b72cb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <stdio.h>
#include "litmus.h"
#include "internal.h"
#include "asm.h"
/* per real-time thread kernel <-> user space flags */
struct np_flag {
#define RT_PREEMPTIVE 0x2050 /* = NP */
#define RT_NON_PREEMPTIVE 0x4e50 /* = P */
unsigned short preemptivity;
#define RT_EXIT_NP_REQUESTED 0x5251 /* = RQ */
unsigned short request;
unsigned int ctr;
};
int register_np_flag(struct np_flag* flag);
int signal_exit_np(void);
#ifndef __sparc__
static __thread struct np_flag np_flag;
#endif
int init_kernel_iface(void)
{
int ret = 0;
#ifndef __sparc__ /* currently not supported in sparc64 */
np_flag.preemptivity = RT_PREEMPTIVE;
np_flag.ctr = 0;
ret = register_np_flag(&np_flag);
check("register_np_flag()");
#endif
return ret;
}
void enter_np(void)
{
#ifndef __sparc__
if (++np_flag.ctr == 1)
{
np_flag.request = 0;
barrier();
np_flag.preemptivity = RT_NON_PREEMPTIVE;
}
#else
fprintf(stderr, "enter_np: not implemented!\n");
#endif
}
void exit_np(void)
{
#ifndef __sparc__
if (--np_flag.ctr == 0)
{
np_flag.preemptivity = RT_PREEMPTIVE;
barrier();
if (np_flag.request == RT_EXIT_NP_REQUESTED)
signal_exit_np();
}
#else
fprintf(stderr, "exit_np: not implemented!\n");
#endif
}
|