aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/dgl.h
blob: acd58f80b58b9c13caf1600b06f70b9a50ed50df (plain) (blame)
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
65
#ifndef __DGL_H_
#define __DGL_H_

#include <litmus/color.h>
#include <linux/list.h>

/*
 * A request for @replica amount of a single resource.
 */
struct dgl_req {
	unsigned short 		replicas;
	struct list_head 	list;
	struct dgl_group_req	*greq;
};

/*
 * Simultaneous @requests for multiple resources.
 */
struct dgl_group_req {
	int 			cpu;
	unsigned long 		*requested;
	unsigned long 		*waiting;

	struct dgl_req	 	*requests;

	unsigned long long	ts;
};

/*
 * A single resource.
 */
struct dgl_resource {
	unsigned long 		free_replicas;
	struct list_head 	waiting;
};

/*
 * A group of resources.
 */
struct dgl {
	struct dgl_resource 	*resources;
	struct dgl_group_req* 	*acquired;

	char 			requests;
	char 			running;
	unsigned long long	ts;

	unsigned long           num_resources;
	unsigned long		num_replicas;
};

void dgl_init(struct dgl *dgl, unsigned long num_resources,
	      unsigned long num_replicas);
void dgl_free(struct dgl *dgl);

void dgl_group_req_init(struct dgl *dgl, struct dgl_group_req *greq);
void dgl_group_req_free(struct dgl_group_req *greq);

void set_req(struct dgl *dgl, struct dgl_group_req *greq,
	     int resource, int replicas);

void add_group_req(struct dgl *dgl, struct dgl_group_req *greq, int cpu);
void remove_group_req(struct dgl *dgl, struct dgl_group_req *greq);

#endif