aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/locking.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/locking.c')
-rw-r--r--litmus/locking.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/litmus/locking.c b/litmus/locking.c
index 58b5edd9df32..f7d33156cf49 100644
--- a/litmus/locking.c
+++ b/litmus/locking.c
@@ -246,6 +246,11 @@ void select_next_lock(dgl_wait_state_t* dgl_wait /*, struct litmus_lock* prev_lo
246 246
247 //WARN_ON(dgl_wait->locks[dgl_wait->last_primary] != prev_lock); 247 //WARN_ON(dgl_wait->locks[dgl_wait->last_primary] != prev_lock);
248 248
249 if (dgl_wait->last_primary == 0) {
250 /* loop around */
251 dgl_wait->last_primary = dgl_wait->size;
252 }
253
249 // note reverse order 254 // note reverse order
250 for(dgl_wait->last_primary = dgl_wait->last_primary - 1; 255 for(dgl_wait->last_primary = dgl_wait->last_primary - 1;
251 dgl_wait->last_primary >= 0; 256 dgl_wait->last_primary >= 0;
@@ -327,6 +332,35 @@ static void snprintf_dgl(char* buf, size_t bsz, struct litmus_lock* dgl_locks[],
327} 332}
328#endif 333#endif
329 334
335
336/* only valid when locks are prioq locks!!!
337 * THE BIG DGL LOCK MUST BE HELD! */
338int __attempt_atomic_dgl_acquire(struct litmus_lock *cur_lock, dgl_wait_state_t *dgl_wait)
339{
340 int i;
341
342 /* check to see if we can take all the locks */
343 for(i = 0; i < dgl_wait->size; ++i) {
344 struct litmus_lock *l = dgl_wait->locks[i];
345 if(!l->ops->dgl_can_quick_lock(l, dgl_wait->task))
346 {
347 return -1;
348 }
349 }
350
351 /* take the locks */
352 for(i = 0; i < dgl_wait->size; ++i) {
353 struct litmus_lock *l = dgl_wait->locks[i];
354
355 l->ops->dgl_quick_lock(l, cur_lock, dgl_wait->task, &dgl_wait->wq_nodes[i]);
356
357 BUG_ON(dgl_wait->task != *(l->nest.owner_ptr));
358 }
359
360 return 0; /* success */
361}
362
363
330static long do_litmus_dgl_lock(dgl_wait_state_t *dgl_wait) 364static long do_litmus_dgl_lock(dgl_wait_state_t *dgl_wait)
331{ 365{
332 int i; 366 int i;
@@ -394,7 +428,6 @@ static long do_litmus_dgl_lock(dgl_wait_state_t *dgl_wait)
394 raw_spin_unlock_irqrestore(dgl_lock, irqflags); // free dgl_lock before suspending 428 raw_spin_unlock_irqrestore(dgl_lock, irqflags); // free dgl_lock before suspending
395 429
396 suspend_for_lock(); // suspend!!! 430 suspend_for_lock(); // suspend!!!
397 //schedule(); // suspend!!!
398 431
399 TS_DGL_LOCK_RESUME; 432 TS_DGL_LOCK_RESUME;
400 433