From 69b88f7b7d51582c6def81a32760d1f957a9675f Mon Sep 17 00:00:00 2001 From: Tanya Amert Date: Wed, 14 Oct 2020 21:07:19 -0400 Subject: Added final step of priority inheritance. --- litmus/reservations/ext_reservation.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/litmus/reservations/ext_reservation.c b/litmus/reservations/ext_reservation.c index ad8bc7238631..0e02b8f2f877 100644 --- a/litmus/reservations/ext_reservation.c +++ b/litmus/reservations/ext_reservation.c @@ -21,6 +21,18 @@ int higher_res_prio(struct reservation* first, if (!first || !second) return first && !second; +#ifdef CONFIG_LITMUS_LOCKING + + /* Check for inherited priorities. Change reservation + * used for comparison in such a case. + */ + if (unlikely(first->inh_res)) + first_task = first->inh_res; + if (unlikely(second->inh_res)) + second_task = second->inh_res; + +#endif + if (first_task->priority > second_task->priority) { return 1; } @@ -29,6 +41,16 @@ int higher_res_prio(struct reservation* first, if (first_task->id < second_task->id) { return 1; } +#ifdef CONFIG_LITMUS_LOCKING + else if (first_task->id == second_task->id) { + /* If the PIDs are the same then the task with the + * inherited priority wins. + */ + if (!second->inh_res) { + return 1; + } + } +#endif } //TODO: TAKE INTO ACCOUNT INH_TASK WHEN DOING PRIO COMPARISONS return 0; /* fall-through. prio(second_task) > prio(first_task) */ -- cgit v1.2.2