-
Notifications
You must be signed in to change notification settings - Fork 4
/
custom_sched.h
81 lines (59 loc) · 1.64 KB
/
custom_sched.h
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
71
72
73
74
75
76
77
78
79
80
81
#ifndef CUSTOM_SCHED_H
#define CUSTOM_SCHED_H
#include <sys/queue.h>
int yield_pcore(int pcoreid);
#ifndef printd
#define printd(...)
#endif
#if defined(__akaros__)
#define PVC_2LS 1
#define TDI 1
#define TDI_YIELDS 1
#define BRUTEX 1
//#define BRUTEX_YIELD_IMMEDIATELY 1
#define ALARM 1
//#define PREFER_UNBLOCKED_SYSC 1
#define MAX_NR_THREADS 50
#else
#define TDI 1
#define TDI_YIELDS 1
//#define BRUTEX 1
//#define BRUTEX_YIELD_IMMEDIATELY 1
//#define PREFER_UNBLOCKED_SYSC 1
#define MAX_NR_THREADS 50
#endif
/* Need this here since the connection struct includes a mutex_t */
struct wthread;
TAILQ_HEAD(wthread_queue, wthread);
typedef struct {
struct wthread_queue waiters;
bool in_use;
} rutex_t;
void wthread_rutex_init(rutex_t *m);
void wthread_rutex_lock(rutex_t *m);
void wthread_rutex_unlock(rutex_t *m);
typedef struct {
struct wthread_queue waiters;
struct spin_pdr_lock lock;
bool in_use;
} mutex_t;
void wthread_mutex_init(mutex_t *m);
void wthread_mutex_lock(mutex_t *m);
void wthread_mutex_unlock(mutex_t *m);
typedef struct {
atomic_t lock;
} brutex_t;
void wthread_brutex_init(brutex_t *m);
void wthread_brutex_lock(brutex_t *m);
void wthread_brutex_unlock(brutex_t *m);
#ifdef BRUTEX
#define mutex_lock(x) wthread_brutex_lock(x)
#define mutex_unlock(x) wthread_brutex_unlock(x)
#define mutex_init(x) wthread_brutex_init(x);
#define mutex_t brutex_t
#else
#define mutex_lock(x) wthread_mutex_lock(x)
#define mutex_unlock(x) wthread_mutex_unlock(x)
#define mutex_init(x) wthread_mutex_init(x);
#endif
#endif // CUSTOM_SCHED_H