-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhilosophersState.cuh
64 lines (50 loc) · 1.31 KB
/
PhilosophersState.cuh
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
#ifndef PHILOSOPHERS_STATE_CUH_
#define PHILOSOPHERS_STATE_CUH_
#include <cstring>
#include "BaseState.cuh"
/**
* All possible states of each philosopher
*/
enum class PhilosophersStatesEnum
{
kThink = 0,
kOne = 1,
kEat = 2,
kFinish = 3
};
/**
* A current state of the philosophers model
*/
class PhilosophersState : public BaseState<PhilosophersState>
{
public:
/**
* The amount of philosophers (= processes) in the model
*/
static const unsigned int kProcesses = 15;
/**
* The amount of nondeterministic choices per state. Always 1
*/
static const unsigned int kNondeterministicChoices = 1;
/**
* The total state space size
*/
static const unsigned int kStateSpaceSize = 14348906; // pow(3, kProcesses) - 1;
/**
* The current state of each philosopher in the model
*/
PhilosophersStatesEnum state[kProcesses];
/**
* The current state of each fork in the model
*
* 0 = resting
* 1 = picked up
*/
bool fork[kProcesses];
__host__ __device__ PhilosophersState();
__host__ __device__ PhilosophersState(const PhilosophersState &obj);
__host__ __device__ void successor_generation(PhilosophersState *successor, unsigned int process, unsigned int ndc);
__host__ __device__ bool violates();
__host__ std::string str();
};
#endif // PHILOSOPHERS_STATE_CUH_