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