diff options
author | Sven Dziadek <s9svdzia@stud.uni-saarland.de> | 2012-04-16 15:00:33 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-07-23 05:57:59 -0400 |
commit | 16c1fb2d4ac691e941456a084284020c63fce93a (patch) | |
tree | 0f7cf24be334788c9f9bb8242966df83f6266dc6 /litmus/locking.c | |
parent | 4bc55d3b64fdf0af17f4777013a74fbef7f40ced (diff) |
P-FP: port P-FP plugin used in B. Brandenburg's
dissertation (branch bbb-diss) to current
version of litmus
This is needed for ongoing projects
I took the unchanged code but removed some leftovers
of OMLP which is not implemented
Diffstat (limited to 'litmus/locking.c')
-rw-r--r-- | litmus/locking.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/litmus/locking.c b/litmus/locking.c index 0c1aa6aa40b7..ca5a073a989e 100644 --- a/litmus/locking.c +++ b/litmus/locking.c | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | #include <litmus/sched_plugin.h> | 5 | #include <litmus/sched_plugin.h> |
6 | #include <litmus/trace.h> | 6 | #include <litmus/trace.h> |
7 | #include <litmus/wait.h> | ||
7 | 8 | ||
8 | static int create_generic_lock(void** obj_ref, obj_type_t type, void* __user arg); | 9 | static int create_generic_lock(void** obj_ref, obj_type_t type, void* __user arg); |
9 | static int open_generic_lock(struct od_table_entry* entry, void* __user arg); | 10 | static int open_generic_lock(struct od_table_entry* entry, void* __user arg); |
@@ -121,6 +122,37 @@ struct task_struct* __waitqueue_remove_first(wait_queue_head_t *wq) | |||
121 | return(t); | 122 | return(t); |
122 | } | 123 | } |
123 | 124 | ||
125 | unsigned int __add_wait_queue_prio_exclusive( | ||
126 | wait_queue_head_t* head, | ||
127 | prio_wait_queue_t *new) | ||
128 | { | ||
129 | struct list_head *pos; | ||
130 | unsigned int passed = 0; | ||
131 | |||
132 | new->wq.flags |= WQ_FLAG_EXCLUSIVE; | ||
133 | |||
134 | /* find a spot where the new entry is less than the next */ | ||
135 | list_for_each(pos, &head->task_list) { | ||
136 | prio_wait_queue_t* queued = list_entry(pos, prio_wait_queue_t, | ||
137 | wq.task_list); | ||
138 | |||
139 | if (unlikely(lt_before(new->priority, queued->priority) || | ||
140 | (new->priority == queued->priority && | ||
141 | new->tie_breaker < queued->tie_breaker))) { | ||
142 | /* pos is not less than new, thus insert here */ | ||
143 | __list_add(&new->wq.task_list, pos->prev, pos); | ||
144 | goto out; | ||
145 | } | ||
146 | passed++; | ||
147 | } | ||
148 | |||
149 | /* if we get to this point either the list is empty or every entry | ||
150 | * queued element is less than new. | ||
151 | * Let's add new to the end. */ | ||
152 | list_add_tail(&new->wq.task_list, &head->task_list); | ||
153 | out: | ||
154 | return passed; | ||
155 | } | ||
124 | 156 | ||
125 | #else | 157 | #else |
126 | 158 | ||