diff options
Diffstat (limited to 'include/litmus/dgl.h')
-rw-r--r-- | include/litmus/dgl.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/include/litmus/dgl.h b/include/litmus/dgl.h new file mode 100644 index 000000000000..989f6c7d5e8e --- /dev/null +++ b/include/litmus/dgl.h | |||
@@ -0,0 +1,53 @@ | |||
1 | #ifndef __DGL_H_ | ||
2 | #define __DGL_H_ | ||
3 | |||
4 | #include <linux/list.h> | ||
5 | |||
6 | #define NUM_REPLICAS 4 | ||
7 | #define NUM_RESOURCES 4 | ||
8 | #define MASK_SIZE (sizeof(unsigned long) * 8) | ||
9 | #define MASK_WORDS (NUM_RESOURCES/MASK_SIZE + (NUM_RESOURCES%MASK_SIZE != 0)) | ||
10 | |||
11 | /* | ||
12 | * A request for @replica amount of a single resource. | ||
13 | */ | ||
14 | struct dgl_req { | ||
15 | unsigned short replicas; | ||
16 | struct list_head list; | ||
17 | }; | ||
18 | |||
19 | /* | ||
20 | * Simultaneous @requests for multiple resources. | ||
21 | */ | ||
22 | struct dgl_group_req { | ||
23 | int cpu; | ||
24 | unsigned long requested[MASK_WORDS]; | ||
25 | unsigned long waiting[MASK_WORDS]; | ||
26 | struct dgl_req requests[NUM_RESOURCES]; | ||
27 | }; | ||
28 | |||
29 | /* | ||
30 | * A single resource. | ||
31 | */ | ||
32 | struct dgl_resource { | ||
33 | unsigned int free_replicas; | ||
34 | struct list_head waiting; | ||
35 | }; | ||
36 | |||
37 | /* | ||
38 | * A group of resources. | ||
39 | */ | ||
40 | struct dgl { | ||
41 | struct dgl_resource resources[NUM_RESOURCES]; | ||
42 | struct dgl_group_req* acquired[NR_CPUS]; | ||
43 | }; | ||
44 | |||
45 | void dgl_init(struct dgl *dgl); | ||
46 | void dgl_group_req_init(struct dgl_group_req *greq); | ||
47 | |||
48 | void set_req(struct dgl_group_req *greq, int resource, int replicas); | ||
49 | |||
50 | void add_group_req(struct dgl *dgl, struct dgl_group_req *greq, int cpu); | ||
51 | void remove_group_req(struct dgl *dgl, struct dgl_group_req *greq); | ||
52 | |||
53 | #endif | ||