From bf34c69c682443b5bf2f9009b1a0039fd60e654f Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Mon, 18 Oct 2010 15:58:27 -0400 Subject: Litmus core: add budget_remaining() helper Quick way to figure out how much budget a LITMUS^RT job has left. --- include/litmus/litmus.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index 674528eece14..69894f59c8d8 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h @@ -85,6 +85,15 @@ inline static int budget_exhausted(struct task_struct* t) return get_exec_time(t) >= get_exec_cost(t); } +inline static lt_t budget_remaining(struct task_struct* t) +{ + if (!budget_exhausted(t)) + return get_exec_time(t) - get_exec_cost(t); + else + /* avoid overflow */ + return 0; +} + #define budget_enforced(t) (tsk_rt(t)->task_params.budget_policy != NO_ENFORCEMENT) -- cgit v1.2.2