aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/ikglp_lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/litmus/ikglp_lock.h')
-rw-r--r--include/litmus/ikglp_lock.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/include/litmus/ikglp_lock.h b/include/litmus/ikglp_lock.h
new file mode 100644
index 000000000000..c0cc04db1bc6
--- /dev/null
+++ b/include/litmus/ikglp_lock.h
@@ -0,0 +1,97 @@
1#ifndef LITMUS_IKGLP_H
2#define LITMUS_IKGLP_H
3
4#include <litmus/litmus.h>
5#include <litmus/binheap.h>
6#include <litmus/locking.h>
7
8typedef struct ikglp_heap_node
9{
10 struct task_struct *task;
11 struct binheap_node node;
12} ikglp_heap_node_t;
13
14struct fifo_queue;
15struct ikglp_wait_state;
16
17typedef struct ikglp_donee_heap_node
18{
19 struct task_struct *task;
20 struct fifo_queue *fq;
21 struct ikglp_wait_state *donor_info; // cross-linked with ikglp_wait_state_t of donor
22
23 struct binheap_node node;
24} ikglp_donee_heap_node_t;
25
26// Maintains the state of a request as it goes through the IKGLP
27typedef struct ikglp_wait_state {
28 struct task_struct *task; // pointer back to the requesting task
29
30 // Data for while waiting in FIFO Queue
31 wait_queue_t fq_node;
32 ikglp_heap_node_t global_heap_node;
33 ikglp_donee_heap_node_t donee_heap_node;
34
35 // Data for while waiting in PQ
36 ikglp_heap_node_t pq_node;
37
38 // Data for while waiting as a donor
39 ikglp_donee_heap_node_t *donee_info; // cross-linked with donee's ikglp_donee_heap_node_t
40 struct nested_info prio_donation;
41 struct binheap_node node;
42} ikglp_wait_state_t;
43
44/* struct for semaphore with priority inheritance */
45struct fifo_queue
46{
47 wait_queue_head_t wait;
48 struct task_struct* owner;
49
50 // used for bookkeepping
51 ikglp_heap_node_t global_heap_node;
52 ikglp_donee_heap_node_t donee_heap_node;
53
54 struct task_struct* hp_waiter;
55 int count; /* number of waiters + holder */
56
57 struct nested_info nest;
58};
59
60struct ikglp_semaphore
61{
62 struct litmus_lock litmus_lock;
63
64 raw_spinlock_t lock;
65 raw_spinlock_t real_lock;
66
67 int nr_replicas; // AKA k
68 int m;
69
70 int max_fifo_len; // max len of a fifo queue
71
72 struct binheap_handle top_m; // min heap, base prio
73 int top_m_size; // number of nodes in top_m
74
75 struct binheap_handle not_top_m; // max heap, base prio
76
77 struct binheap_handle donees; // min-heap, base prio
78 struct fifo_queue *shortest_fifo_queue; // pointer to shortest fifo queue
79
80 /* data structures for holding requests */
81 struct fifo_queue *fifo_queues; // array nr_replicas in length
82 struct binheap_handle priority_queue; // max-heap, base prio
83 struct binheap_handle donors; // max-heap, base prio
84};
85
86static inline struct ikglp_semaphore* ikglp_from_lock(struct litmus_lock* lock)
87{
88 return container_of(lock, struct ikglp_semaphore, litmus_lock);
89}
90
91int ikglp_lock(struct litmus_lock* l);
92int ikglp_unlock(struct litmus_lock* l);
93int ikglp_close(struct litmus_lock* l);
94void ikglp_free(struct litmus_lock* l);
95struct litmus_lock* ikglp_new(int m, struct litmus_lock_ops*, void* __user arg);
96
97#endif