aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2012-05-04 16:52:44 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2012-05-04 16:52:44 -0400
commit2f421a06c3663fff3e3f0d0238f6d4651a8cb50d (patch)
tree791503b7c7893406786b44b739fd965f5dcb6932 /include
parent788c87d653beb3c28a7b44d79b09ddcab5f7aa41 (diff)
Group locks now allocate fields dynamically
Diffstat (limited to 'include')
-rw-r--r--include/litmus/dgl.h36
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 */
17struct dgl_req { 10struct 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 */
25struct dgl_group_req { 19struct 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 */
36struct dgl_resource { 32struct 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 */
44struct dgl { 40struct 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
53void dgl_init(struct dgl *dgl); 52void dgl_init(struct dgl *dgl, unsigned long num_resources,
54void dgl_group_req_init(struct dgl_group_req *greq); 53 unsigned long num_replicas);
54void dgl_free(struct dgl *dgl);
55
56void dgl_group_req_init(struct dgl *dgl, struct dgl_group_req *greq);
57void dgl_group_req_free(struct dgl_group_req *greq);
55 58
56void set_req(struct dgl_group_req *greq, int resource, int replicas); 59void set_req(struct dgl *dgl, struct dgl_group_req *greq,
60 int resource, int replicas);
57 61
58void add_group_req(struct dgl *dgl, struct dgl_group_req *greq, int cpu); 62void 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); 63void remove_group_req(struct dgl *dgl, struct dgl_group_req *greq);