diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/litmus/dgl.h | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/include/litmus/dgl.h b/include/litmus/dgl.h index 2bf61d4a7547..acd58f80b58b 100644 --- a/include/litmus/dgl.h +++ b/include/litmus/dgl.h | |||
@@ -4,19 +4,13 @@ | |||
4 | #include <litmus/color.h> | 4 | #include <litmus/color.h> |
5 | #include <linux/list.h> | 5 | #include <linux/list.h> |
6 | 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 | /* | 7 | /* |
15 | * A request for @replica amount of a single resource. | 8 | * A request for @replica amount of a single resource. |
16 | */ | 9 | */ |
17 | struct dgl_req { | 10 | struct dgl_req { |
18 | unsigned short replicas; | 11 | unsigned short replicas; |
19 | struct list_head list; | 12 | struct list_head list; |
13 | struct dgl_group_req *greq; | ||
20 | }; | 14 | }; |
21 | 15 | ||
22 | /* | 16 | /* |
@@ -24,9 +18,11 @@ struct dgl_req { | |||
24 | */ | 18 | */ |
25 | struct dgl_group_req { | 19 | struct dgl_group_req { |
26 | int cpu; | 20 | int cpu; |
27 | unsigned long requested[MASK_WORDS]; | 21 | unsigned long *requested; |
28 | unsigned long waiting[MASK_WORDS]; | 22 | unsigned long *waiting; |
29 | struct dgl_req requests[NUM_RESOURCES]; | 23 | |
24 | struct dgl_req *requests; | ||
25 | |||
30 | unsigned long long ts; | 26 | unsigned long long ts; |
31 | }; | 27 | }; |
32 | 28 | ||
@@ -34,7 +30,7 @@ struct dgl_group_req { | |||
34 | * A single resource. | 30 | * A single resource. |
35 | */ | 31 | */ |
36 | struct dgl_resource { | 32 | struct dgl_resource { |
37 | unsigned int free_replicas; | 33 | unsigned long free_replicas; |
38 | struct list_head waiting; | 34 | struct list_head waiting; |
39 | }; | 35 | }; |
40 | 36 | ||
@@ -42,18 +38,26 @@ struct dgl_resource { | |||
42 | * A group of resources. | 38 | * A group of resources. |
43 | */ | 39 | */ |
44 | struct dgl { | 40 | struct dgl { |
45 | struct dgl_resource resources[NUM_RESOURCES]; | 41 | struct dgl_resource *resources; |
46 | struct dgl_group_req* acquired[NR_CPUS]; | 42 | struct dgl_group_req* *acquired; |
47 | 43 | ||
48 | char requests; | 44 | char requests; |
49 | char running; | 45 | char running; |
50 | unsigned long long ts; | 46 | unsigned long long ts; |
47 | |||
48 | unsigned long num_resources; | ||
49 | unsigned long num_replicas; | ||
51 | }; | 50 | }; |
52 | 51 | ||
53 | void dgl_init(struct dgl *dgl); | 52 | void dgl_init(struct dgl *dgl, unsigned long num_resources, |
54 | void dgl_group_req_init(struct dgl_group_req *greq); | 53 | unsigned long num_replicas); |
54 | void dgl_free(struct dgl *dgl); | ||
55 | |||
56 | void dgl_group_req_init(struct dgl *dgl, struct dgl_group_req *greq); | ||
57 | void dgl_group_req_free(struct dgl_group_req *greq); | ||
55 | 58 | ||
56 | void set_req(struct dgl_group_req *greq, int resource, int replicas); | 59 | void set_req(struct dgl *dgl, struct dgl_group_req *greq, |
60 | int resource, int replicas); | ||
57 | 61 | ||
58 | void add_group_req(struct dgl *dgl, struct dgl_group_req *greq, int cpu); | 62 | void add_group_req(struct dgl *dgl, struct dgl_group_req *greq, int cpu); |
59 | void remove_group_req(struct dgl *dgl, struct dgl_group_req *greq); | 63 | void remove_group_req(struct dgl *dgl, struct dgl_group_req *greq); |