aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/prioq_lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/litmus/prioq_lock.h')
-rw-r--r--include/litmus/prioq_lock.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/litmus/prioq_lock.h b/include/litmus/prioq_lock.h
new file mode 100644
index 000000000000..f3c11d241991
--- /dev/null
+++ b/include/litmus/prioq_lock.h
@@ -0,0 +1,61 @@
1#ifndef LITMUS_PRIOQ_H
2#define LITMUS_PRIOQ_H
3
4#include <litmus/litmus.h>
5#include <litmus/binheap.h>
6#include <litmus/locking.h>
7
8/* struct for semaphore with priority inheritance */
9struct prioq_mutex {
10 struct litmus_lock litmus_lock;
11
12 /* current resource holder */
13 struct task_struct *owner;
14
15 /* highest-priority waiter */
16 struct task_struct *hp_waiter;
17
18 /* priority-ordered queue of waiting tasks.
19 * Ironically, we don't use a binheap because that would make DGL
20 * implementation a LOT harder. */
21 wait_queue_head_t wait;
22
23 /* we do some nesting within spinlocks, so we can't use the normal
24 sleeplocks found in wait_queue_head_t. */
25 raw_spinlock_t lock;
26};
27
28static inline struct prioq_mutex* prioq_mutex_from_lock(struct litmus_lock* lock)
29{
30 return container_of(lock, struct prioq_mutex, litmus_lock);
31}
32
33#ifdef CONFIG_LITMUS_DGL_SUPPORT
34int prioq_mutex_is_owner(struct litmus_lock *l, struct task_struct *t);
35int prioq_mutex_dgl_lock(struct litmus_lock *l, dgl_wait_state_t* dgl_wait, wait_queue_t* wq_node);
36void prioq_mutex_enable_priority(struct litmus_lock *l, dgl_wait_state_t* dgl_wait);
37void prioq_mutex_dgl_quick_lock(struct litmus_lock *l, struct litmus_lock *cur_lock,
38 struct task_struct* t, wait_queue_t *q);
39int prioq_mutex_dgl_can_quick_lock(struct litmus_lock *l, struct task_struct *t);
40#endif
41
42void prioq_mutex_propagate_increase_inheritance(struct litmus_lock* l,
43 struct task_struct* t,
44 raw_spinlock_t* to_unlock,
45 unsigned long irqflags);
46
47void prioq_mutex_propagate_decrease_inheritance(struct litmus_lock* l,
48 struct task_struct* t,
49 raw_spinlock_t* to_unlock,
50 unsigned long irqflags);
51
52
53int prioq_mutex_lock(struct litmus_lock* l);
54int prioq_mutex_unlock(struct litmus_lock* l);
55int prioq_mutex_close(struct litmus_lock* l);
56void prioq_mutex_free(struct litmus_lock* l);
57struct litmus_lock* prioq_mutex_new(struct litmus_lock_ops*);
58
59
60#endif
61