-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgthread.hh
More file actions
52 lines (38 loc) · 1.03 KB
/
gthread.hh
File metadata and controls
52 lines (38 loc) · 1.03 KB
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
#ifndef GTHREAD_HH_
#define GTHREAD_HH_
#include <pthread.h>
#include <setjmp.h>
#include <unistd.h>
#include <unordered_set>
#include "stack_context.hh"
#include "util.hh"
struct gthread_t {
pid_t tid;
void *retval;
};
// Possibly change to template in the future
class GThread {
public:
GThread() = delete;
// Create a thread
static void Create(gthread_t *t, void *(*start_routine)(void *), void *args);
// Join a thread
static void Join(gthread_t t);
// Begins an atomic section
static void AtomicBegin();
// Ends an atomic section
static void AtomicEnd();
// Initialize GThread
static void InitGThread();
private:
// Abort and rollbakc an atomic section
static void AtomicAbort();
// Commit an atomic section
static bool AtomicCommit();
// Initialize stack context
static void InitStackContext();
static pid_t tid_; // tid of current processor
static pid_t predecessor_; // predecessor's process id
static StackContext context_; // stack context
};
#endif // GTHREAD_HH_