-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsync.h
70 lines (60 loc) · 1.53 KB
/
sync.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
/* sync.h
*
* Copyright (C) 2017 Alexandre Luiz Brisighello Filho
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef SYNC_H_
#define SYNC_H_
#include "pin.H"
#define WATCHER_SLEEP 2 // Seconds between each watchers check.
// --- Communication related ---
typedef enum {
ACTION_DONE = 0,
ACTION_REGISTER = 1,
ACTION_FINI = 2,
ACTION_LOCK_DESTROY = 3,
ACTION_LOCK_INIT = 4,
ACTION_LOCK = 5,
ACTION_TRY_LOCK = 6,
ACTION_UNLOCK = 7,
ACTION_BEFORE_CREATE = 8,
ACTION_BEFORE_JOIN = 9,
ACTION_AFTER_CREATE = 10,
ACTION_SEM_DESTROY = 11,
ACTION_SEM_GETVALUE = 12,
ACTION_SEM_INIT = 13,
ACTION_SEM_POST = 14,
ACTION_SEM_TRYWAIT = 15,
ACTION_SEM_WAIT = 16,
ACTION_RWLOCK_INIT = 17,
ACTION_RWLOCK_DESTROY = 18,
ACTION_RWLOCK_RDLOCK = 19,
ACTION_RWLOCK_TRYRDLOCK = 20,
ACTION_RWLOCK_WRLOCK = 21,
ACTION_RWLOCK_TRYWRLOCK = 22,
ACTION_RWLOCK_UNLOCK = 23,
ACTION_COND_BROADCAST = 24,
ACTION_COND_DESTROY = 25,
ACTION_COND_INIT = 26,
ACTION_COND_SIGNAL = 27,
ACTION_COND_WAIT = 28,
} ACTION_TYPE;
// Arguments are used to pass data to/from sync.
struct ACTION_ARG {
void *p_1;
void *p_2;
int i;
};
typedef struct _ACTION ACTION;
struct _ACTION {
THREADID tid;
ACTION_TYPE action_type;
ACTION_ARG arg;
};
// Init sync structure
void sync_init(int pram);
// Perform a sync based on a valid action
void sync(ACTION *action);
#endif // SYNC_H_