From 6a225701acf7d79f292eeffcd99d6f00b02c180b Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Fri, 7 Sep 2012 23:25:01 -0400 Subject: Infrastructure for Litmus signals. Added signals to Litmus. Specifcally, SIG_BUDGET signals are delivered (when requested by real-time tasks) when a budget is exceeded. Note: pfair not currently supported (but it probably could be). --- include/litmus/budget.h | 20 +++++++++++++++++--- include/litmus/rt_param.h | 16 +++++++++++++++- include/litmus/signal.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 include/litmus/signal.h (limited to 'include/litmus') diff --git a/include/litmus/budget.h b/include/litmus/budget.h index 33344ee8d5f9..763b31c0e9f6 100644 --- a/include/litmus/budget.h +++ b/include/litmus/budget.h @@ -5,6 +5,9 @@ * the next task. */ void update_enforcement_timer(struct task_struct* t); +/* Send SIG_BUDGET to a real-time task. */ +void send_sigbudget(struct task_struct* t); + inline static int budget_exhausted(struct task_struct* t) { return get_exec_time(t) >= get_exec_cost(t); @@ -19,10 +22,21 @@ inline static lt_t budget_remaining(struct task_struct* t) return 0; } -#define budget_enforced(t) (tsk_rt(t)->task_params.budget_policy != NO_ENFORCEMENT) +#define budget_enforced(t) (\ + tsk_rt(t)->task_params.budget_policy != NO_ENFORCEMENT) + +#define budget_precisely_tracked(t) (\ + tsk_rt(t)->task_params.budget_policy == PRECISE_ENFORCEMENT || \ + tsk_rt(t)->task_params.budget_signal_policy == PRECISE_SIGNALS) + +#define budget_signalled(t) (\ + tsk_rt(t)->task_params.budget_signal_policy != NO_SIGNALS) + +#define budget_precisely_signalled(t) (\ + tsk_rt(t)->task_params.budget_policy == PRECISE_SIGNALS) -#define budget_precisely_enforced(t) (tsk_rt(t)->task_params.budget_policy \ - == PRECISE_ENFORCEMENT) +#define sigbudget_sent(t) (\ + test_bit(RT_JOB_SIG_BUDGET_SENT, &tsk_rt(t)->job_params.flags)) static inline int requeue_preempted_job(struct task_struct* t) { diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index 89ac0dda7d3d..637fe6b84f9d 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h @@ -30,9 +30,15 @@ typedef enum { typedef enum { NO_ENFORCEMENT, /* job may overrun unhindered */ QUANTUM_ENFORCEMENT, /* budgets are only checked on quantum boundaries */ - PRECISE_ENFORCEMENT /* budgets are enforced with hrtimers */ + PRECISE_ENFORCEMENT, /* budgets are enforced with hrtimers */ } budget_policy_t; +typedef enum { + NO_SIGNALS, /* job receives no signals when it exhausts its budget */ + QUANTUM_SIGNALS, /* budget signals are only sent on quantum boundaries */ + PRECISE_SIGNALS, /* budget signals are triggered with hrtimers */ +} budget_signal_policy_t; + /* We use the common priority interpretation "lower index == higher priority", * which is commonly used in fixed-priority schedulability analysis papers. * So, a numerically lower priority value implies higher scheduling priority, @@ -62,6 +68,7 @@ struct rt_task { unsigned int priority; task_class_t cls; budget_policy_t budget_policy; /* ignored by pfair */ + budget_signal_policy_t budget_signal_policy; /* currently ignored by pfair */ }; union np_flag { @@ -118,8 +125,15 @@ struct rt_job { * Increase this sequence number when a job is released. */ unsigned int job_no; + + /* bits: + * 0th: Set if a budget exhaustion signal has already been sent for + * the current job. */ + unsigned long flags; }; +#define RT_JOB_SIG_BUDGET_SENT 0 + struct pfair_param; /* RT task parameters for scheduling extensions diff --git a/include/litmus/signal.h b/include/litmus/signal.h new file mode 100644 index 000000000000..b3d82b294984 --- /dev/null +++ b/include/litmus/signal.h @@ -0,0 +1,47 @@ +#ifndef LITMUS_SIGNAL_H +#define LITMUS_SIGNAL_H + +#ifdef __KERNEL__ +#include +#else +#include +#endif + +/* Signals used by Litmus to asynchronously communicate events + * to real-time tasks. + * + * Signal values overlap with [SIGRTMIN, SIGRTMAX], so beware of + * application-level conflicts when dealing with COTS user-level + * code. + */ + +/* Sent to a Litmus task when all of the following conditions are true: + * (1) The task has exhausted its budget. + * (2) budget_signal_policy is QUANTUM_SIGNALS or PRECISE_SIGNALS. + * + * Note: If a task does not have a registered handler for SIG_BUDGET, + * the signal will cause the task to terminate (default action). + */ + +/* Assigned values start at SIGRTMAX and decrease, hopefully reducing + * likelihood of user-level conflicts. + */ +#define SIG_BUDGET (SIGRTMAX - 0) + +/* +Future signals could include: + +#define SIG_DEADLINE_MISS (SIGRTMAX - 1) +#define SIG_CRIT_LEVEL_CHANGE (SIGRTMAX - 2) +*/ + +#define SIGLITMUSMIN SIG_BUDGET + +#ifdef __KERNEL__ +#if (SIGLITMUSMIN < SIGRTMIN) +/* no compile-time check in user-space since SIGRTMIN may be a variable. */ +#error "Too many LITMUS^RT signals!" +#endif +#endif + +#endif -- cgit v1.2.2