Skip to content
Snippets Groups Projects
Commit 80143d68 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

more cleanup.

parent a504ff46
No related branches found
No related tags found
No related merge requests found
...@@ -686,16 +686,14 @@ int qsched_lockres(struct qsched *s, int rid) { ...@@ -686,16 +686,14 @@ int qsched_lockres(struct qsched *s, int rid) {
*/ */
void qsched_unlockres(struct qsched *s, int rid) { void qsched_unlockres(struct qsched *s, int rid) {
int finger;
/* Unlock the resource. */ /* Unlock the resource. */
lock_unlock_blind(&s->res[rid].lock); lock_unlock_blind(&s->res[rid].lock);
/* Go back up the tree and undo the holds. */ /* Go back up the tree and undo the holds. */
for (finger = s->res[rid].parent; finger != qsched_res_none; for (int finger = s->res[rid].parent; finger != qsched_res_none;
finger = s->res[finger].parent) finger = s->res[finger].parent) {
atomic_dec(&s->res[finger].hold); atomic_dec(&s->res[finger].hold);
}
} }
/** /**
...@@ -709,23 +707,24 @@ void qsched_unlockres(struct qsched *s, int rid) { ...@@ -709,23 +707,24 @@ void qsched_unlockres(struct qsched *s, int rid) {
int qsched_locktask(struct qsched *s, int tid) { int qsched_locktask(struct qsched *s, int tid) {
int k;
struct task *t;
TIMER_TIC TIMER_TIC
/* Get a pointer on the task. */ /* Get a pointer on the task. */
t = &s->tasks[tid]; struct task *t = &s->tasks[tid];
/* Try to lock all the task's locks. */ /* Try to lock all the task's locks. */
for (k = 0; k < t->nr_locks; k++) int lock_id;
if (qsched_lockres(s, t->locks[k]) == 0) break; for (lock_id = 0; lock_id < t->nr_locks; lock_id++) {
if (qsched_lockres(s, t->locks[lock_id]) == 0) break;
}
/* If I didn't get all the locks... */ /* If I didn't get all the locks... */
if (k < t->nr_locks) { if (lock_id < t->nr_locks) {
/* Unroll the locks I got. */ /* Unroll the locks I got. */
for (k -= 1; k >= 0; k--) qsched_unlockres(s, t->locks[k]); for (lock_id -= 1; lock_id >= 0; lock_id--) {
qsched_unlockres(s, t->locks[lock_id]);
}
/* Fail. */ /* Fail. */
TIMER_TOC(s, qsched_timer_lock) TIMER_TOC(s, qsched_timer_lock)
...@@ -749,16 +748,13 @@ int qsched_locktask(struct qsched *s, int tid) { ...@@ -749,16 +748,13 @@ int qsched_locktask(struct qsched *s, int tid) {
void qsched_unlocktask(struct qsched *s, int tid) { void qsched_unlocktask(struct qsched *s, int tid) {
int k;
struct task *t;
TIMER_TIC TIMER_TIC
/* Get a pointer on the task. */ /* Get a pointer on the task. */
t = &s->tasks[tid]; struct task *t = &s->tasks[tid];
/* Unlock the used resources. */ /* Unlock the used resources. */
for (k = 0; k < t->nr_locks; k++) qsched_unlockres(s, t->locks[k]); for (int k = 0; k < t->nr_locks; k++) qsched_unlockres(s, t->locks[k]);
TIMER_TOC(s, qsched_timer_lock) TIMER_TOC(s, qsched_timer_lock)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment