**2.1 Related work**

2 Will-be-set-by-IN-TECH

*Quality of Service (QoS)* generally refers to a broad collection of networking technologies and techniques. QoS refers to the ability of a network to deliver predictable results. Traditional QoS characteristics include availability, bandwidth, delay or delay jitter (Huston, 2000). However, QoS demands that no task be late (Krings & Azadmanesh, 1999) in hard real-time systems. QoS represents the quantified ratio of tasks that may not be executed – i.e. the total amount of work not contributing to the value of the system – in firm real-time systems. Delay and delay jitter are eliminated from consideration in both cases. Perfect QoS characterization proves to be difficult at the application level. It would be desirable that the scheduling policy adapts to changes in user QoS requirements. Such policy should strive to achieve the desired QoS in an environment with variable resources as well as complex and variable application demands. Consequently, this chapter adresses consideration of the control of the deadline

Let us consider a real-time monitoring system in charge of sampling key environmental indicators such as ambient temperature, carbon dioxide levels, relative humidity, wind speed/direction or solar radiation. Wireless sensor networks are practical and cost effective solutions for such monitoring. The hardware of a node basically includes various sensors, analog-to-digital converters, data storage, a radio (transceiver) and a microprocessor. Environmental data are collected periodically from the sensors and communicated from the sensor node to a base station as depicted in Figure 1. Note that the sampling rate of sensor data may vary from 5 seconds to 10 minutes according to the nature of the measurement.

A real-time monitoring system must provide updated data within strict time constraints. It is

Such a real-time system is often operated in environments that are subject to significant uncertainties. Some parameters such as emergency events, asynchronous demands from external devices (e.g. base station requests for statistical computations on sampled data) or

essential to have an efficient real-time scheduling of all the periodic sampling tasks.

Fig. 1. Simplified architecture of a real-time wireless surveillance application

**1.3.1 Typical example: a wireless autonomous surveillance system**

**1.2 Quality of Service (QoS) requirements**

miss ratios as a QoS concern.

**1.3 Targeted applications**

**1.3.2 Scheduling issue**

Different approaches have been proposed in order to specify firm real-time systems. In (Hamdaoui & Ramanathan, 1995), the concept of *(m,k)-firm* deadlines permits us to model tasks that have to meet *m* deadlines every *k* consecutive instances. The *Distance-Based Priority (DBP)* scheme increases the priority of a job in danger of missing more than *m* deadlines over a sliding window of *k* instances for service. In order to specify a task that tolerates *x* deadlines missed over a finite range or window among *y* consecutive instances, a *windowed lost rate* is also proposed in (West & Poellabauer, 2000). In (Bernat et al., 2001), the authors describe a more general specification of the distribution of met and lost deadlines. *Virtual Deadline Scheduling (VDS)* (West et al., 2004) and *Dynamic Window-Constrained Scheduling (DWCS)* (Zhang et al., 2004) are other existing schedulers provably superior to *DBP* for a number of specific and non-trivial situations.

The notion of *skip factor* is presented in (Koren & Shasha, 1995). The skip factor of a task equal to *s* means that the task will have one instance skipped out of *s*. It is a specific case of the *(m,k)-firm* model with *m* = *k* − 1. Skipping some task instances then permits us to transform an overload situation into an underload one. Making optimal use of skips has been proved to be an NP-hard problem. (*m*,*k*)-hard schedulers are presented in (Bernat & Burns, 1997). Most of these approaches require off-line feasibility tests to ensure a predictable service.

Scheduling hybrid task sets composed of skippable periodic and soft aperiodic tasks has been studied in (Buttazzo & Caccamo, 1999; Caccamo & Buttazzo, 1997). A scheduling algorithm based on a variant of *Earliest Deadline First (EDF)* exploits skips under the *Total Bandwith Server (TBS)*. In our previous work (Marchand & Silly-Chetto, 2005; 2006), we make use of the same approach with the *Earliest Deadline as Late as possible server (EDL)*. These results led us to propose a raw version of the *Red tasks as Late as Possible (RLP)* algorithm (idle time schedule based on red tasks only) (Marchand, 2006; Marchand & Chetto, 2008).

in the Firm Real-Time Systems 5

Quality of Service Scheduling in the Firm Real-Time Systems 195

(Caccamo & Buttazzo, 1997) introduce the notion of *equivalent utilization factor* defined as

**DEFINITION 1.** *Given a set* Γ = {*Ti*(*pi*, *ci*,*si*)} *of n skippable periodic tasks, the equivalent*

∑*<sup>i</sup> D*(*i*, [0, *L*])

<sup>−</sup> *<sup>L</sup> pisi*

*pi*

They also provide a sufficient condition in (Caccamo & Buttazzo, 1998) for guaranteeing a

The first algorithm called Red Task Only (RTO) (Koren & Shasha, 1995) always rejects the blue instances whereas the red ones are scheduled according to EDF. Deadline ties are broken in favor of the task with the earliest release time. Generally speaking, RTO is not optimal. However, it becomes optimal under the particular deeply red task model where all tasks are synchronously activated and the first *si* − 1 instances of every task *Ti* are red. The scheduling decision runs in the worst-case in *O*(*n*2) where all the *n* tasks are released simultaneously.

Figure 3 depicts a RTO schedule for the task set T = {*T*0, *T*1, *T*2, *T*3}. Table 1 gives the characteristics of T . Tasks have uniform skip factor *si* = 2. The total processor utilization

> Task *T*<sup>0</sup> *T*<sup>1</sup> *T*<sup>2</sup> *T*<sup>3</sup> *ci* 4 6 9 4 *pi* 36 24 18 12

The schedule produced by RTO exhibits the lowest acceptable QoS level for the task set . All

The second scheduling algorithm called Blue When Possible (BWP) algorithm (Koren & Shasha, 1995) is an improvement of RTO. Blue instances can execute only if there are no red ready instances. Deadline ties are still broken in favor of the task with the earliest release time. BWP improves RTO in that it offers a higher QoS resulting from the successful completions of

*pi* is equal to 1.19. The equivalent processor utilization *U*<sup>∗</sup>

consequently guarantees the feasibility of the task set under minimal QoS.

blue instances are systematically rejected every *si* periods for each task.

*U*∗

*<sup>L</sup>* (3)

*<sup>p</sup>* ≤ 1. (5)

�)*ci*. (4)

*<sup>p</sup>* is equal to 0.79. This

*U*∗ *<sup>p</sup>* = max *L*≥0

*<sup>D</sup>*(*i*, [0, *<sup>L</sup>*]) = (� *<sup>L</sup>*

follows.

*where*

*utilization factor is defined as:*

feasible schedule of a set of skippable tasks:

**2.4 Skip-over scheduling algorithms**

**2.4.1 RTO (Red Tasks Only)**

Table 1. A basic periodic task set

**2.4.2 BWP (Blue When Possible)**

*Up* = ∑ *ci*

blue instances.

**THEOREM 1.** *A set* Γ *of skippable periodic tasks is schedulable if*

In contrast, tasks with soft real-time constraints still have a value even when completing after their deadlines. In this case, task overruns can cause overload situations that may be managed by overrun handling mechanisms such as *Overrun Server Method (OSM)* (Tia et al., 1995), *CApacity SHaring (CASH)* (Caccamo et al., 2000) or *Randomized Dropping (RD)* (Bello & Kim, 2007). A more complete survey on overrun handling approaches in soft real-time systems can be found in (Asiaban et al. , 2009).

#### **2.2 The skip-over model**

Each periodic task *Ti* is characterized by a worst-case computation time *ci*, a period *pi*, a relative deadline equal to its period and a skip factor *si* – which gives the tolerance of this task to missing deadlines – 2 ≤ *si* ≤ ∞. Every periodic task instance can be either *red* or *blue* under the terminology introduced in (Koren & Shasha, 1995). A red instance must complete before its deadline; a blue instance can be aborted at any time. The operational specification of a skippable periodic task *Ti* is composed of four characteristics: (1) the distance between two consecutive skips must be at least *si* periods, (2) if a *blue* instance is skipped, then the next *si* − 1 instances are necessarily *red*, (3) if a *blue* instance completes successfully, the next instance is also *blue* and (4) the first *si* − 1 instances are *red*. The assumption *si* ≥ 2 implies that, if a *blue* instance is skipped, then the next one must be *red*. The assumption *si* = ∞ signifies that no skip is authorized for task *Ti*. Skips permit us to schedule systems that might otherwise be overloaded. The system is overloaded since *Up* = ∑*<sup>n</sup> <sup>i</sup>*=<sup>1</sup> *ci pi* <sup>=</sup> <sup>4</sup> <sup>6</sup> <sup>+</sup> <sup>1</sup> <sup>2</sup> = 1.17 as shown in Figure 2. Allowing *T*<sup>2</sup> to skip one instance over three enables us to produce a feasible schedule.

Fig. 2. A schedule with the Skip-Over model

#### **2.3 Feasibility test for skippable periodic task sets**

(Liu &Layland, 1973) show that a task set {*Ti*(*ci*, *pi*); 1 ≤ *i* ≤ *n*} is schedulable if and only if its *cumulative processor utilization* (ignoring skips) is not greater than 1, i.e.,

$$\sum\_{i=1}^{n} \frac{c\_i}{p\_i} \le 1.\tag{1}$$

(Koren & Shasha, 1995) prove that the problem of determining whether a set of periodic occasionally skippable tasks is schedulable, is NP-hard. However, they prove the following necessary schedulability condition for a given set Γ = {*Ti*(*pi*, *ci*,*si*)} of skippable periodic tasks:

$$\sum\_{i=1}^{n} \frac{c\_i(s\_i - 1)}{p\_i s\_i} \le 1. \tag{2}$$

(Caccamo & Buttazzo, 1997) introduce the notion of *equivalent utilization factor* defined as follows.

**DEFINITION 1.** *Given a set* Γ = {*Ti*(*pi*, *ci*,*si*)} *of n skippable periodic tasks, the equivalent utilization factor is defined as:*

$$\mathcal{U}\_p^\* = \max\_{L \ge 0} \frac{\sum\_i D(i, [0, L])}{L} \tag{3}$$

*where*

4 Will-be-set-by-IN-TECH

In contrast, tasks with soft real-time constraints still have a value even when completing after their deadlines. In this case, task overruns can cause overload situations that may be managed by overrun handling mechanisms such as *Overrun Server Method (OSM)* (Tia et al., 1995), *CApacity SHaring (CASH)* (Caccamo et al., 2000) or *Randomized Dropping (RD)* (Bello & Kim, 2007). A more complete survey on overrun handling approaches in soft real-time

Each periodic task *Ti* is characterized by a worst-case computation time *ci*, a period *pi*, a relative deadline equal to its period and a skip factor *si* – which gives the tolerance of this task to missing deadlines – 2 ≤ *si* ≤ ∞. Every periodic task instance can be either *red* or *blue* under the terminology introduced in (Koren & Shasha, 1995). A red instance must complete before its deadline; a blue instance can be aborted at any time. The operational specification of a skippable periodic task *Ti* is composed of four characteristics: (1) the distance between two consecutive skips must be at least *si* periods, (2) if a *blue* instance is skipped, then the next *si* − 1 instances are necessarily *red*, (3) if a *blue* instance completes successfully, the next instance is also *blue* and (4) the first *si* − 1 instances are *red*. The assumption *si* ≥ 2 implies that, if a *blue* instance is skipped, then the next one must be *red*. The assumption *si* = ∞ signifies that no skip is authorized for task *Ti*. Skips permit us to schedule systems that might

shown in Figure 2. Allowing *T*<sup>2</sup> to skip one instance over three enables us to produce a feasible

✻ ✻ ✻ ✻

✻ ✻ ✻ ✻ ✻ ✻ ✻ ✻ ✻ ✻ 0 6 12 18

*skip skip skip*

0 2 4 6 8 10 12 14 16 18

(Liu &Layland, 1973) show that a task set {*Ti*(*ci*, *pi*); 1 ≤ *i* ≤ *n*} is schedulable if and only if

(Koren & Shasha, 1995) prove that the problem of determining whether a set of periodic occasionally skippable tasks is schedulable, is NP-hard. However, they prove the following necessary schedulability condition for a given set Γ = {*Ti*(*pi*, *ci*,*si*)} of skippable periodic

> *ci*(*si* − 1) *pisi*

*ci pi*

*n* ∑ *i*=1

its *cumulative processor utilization* (ignoring skips) is not greater than 1, i.e.,

*n* ∑ *i*=1 *<sup>i</sup>*=<sup>1</sup> *ci pi* <sup>=</sup> <sup>4</sup>

≤ 1. (1)

≤ 1. (2)

<sup>6</sup> <sup>+</sup> <sup>1</sup>

✲

✲

<sup>2</sup> = 1.17 as

otherwise be overloaded. The system is overloaded since *Up* = ∑*<sup>n</sup>*

systems can be found in (Asiaban et al. , 2009).

**2.2 The skip-over model**

schedule.

tasks:

*T*1(4, 6, ∞)

*T*2(1, 2, 3)

Fig. 2. A schedule with the Skip-Over model

**2.3 Feasibility test for skippable periodic task sets**

$$D(i\_\prime[0, L]) = (\lfloor \frac{L}{p\_i} - \frac{L}{p\_i s\_i} \rfloor) c\_i. \tag{4}$$

They also provide a sufficient condition in (Caccamo & Buttazzo, 1998) for guaranteeing a feasible schedule of a set of skippable tasks:

**THEOREM 1.** *A set* Γ *of skippable periodic tasks is schedulable if*

$$
\mathcal{U}\_p^\* \le 1.\tag{5}
$$

#### **2.4 Skip-over scheduling algorithms**

#### **2.4.1 RTO (Red Tasks Only)**

The first algorithm called Red Task Only (RTO) (Koren & Shasha, 1995) always rejects the blue instances whereas the red ones are scheduled according to EDF. Deadline ties are broken in favor of the task with the earliest release time. Generally speaking, RTO is not optimal. However, it becomes optimal under the particular deeply red task model where all tasks are synchronously activated and the first *si* − 1 instances of every task *Ti* are red. The scheduling decision runs in the worst-case in *O*(*n*2) where all the *n* tasks are released simultaneously.

Figure 3 depicts a RTO schedule for the task set T = {*T*0, *T*1, *T*2, *T*3}. Table 1 gives the characteristics of T . Tasks have uniform skip factor *si* = 2. The total processor utilization *Up* = ∑ *ci pi* is equal to 1.19. The equivalent processor utilization *U*<sup>∗</sup> *<sup>p</sup>* is equal to 0.79. This consequently guarantees the feasibility of the task set under minimal QoS.


Table 1. A basic periodic task set

The schedule produced by RTO exhibits the lowest acceptable QoS level for the task set . All blue instances are systematically rejected every *si* periods for each task.

#### **2.4.2 BWP (Blue When Possible)**

The second scheduling algorithm called Blue When Possible (BWP) algorithm (Koren & Shasha, 1995) is an improvement of RTO. Blue instances can execute only if there are no red ready instances. Deadline ties are still broken in favor of the task with the earliest release time. BWP improves RTO in that it offers a higher QoS resulting from the successful completions of blue instances.

in the Firm Real-Time Systems 7

Quality of Service Scheduling in the Firm Real-Time Systems 197

• *D*, called static idle time vector. *D* represents the lengths of the idle times which start at

The dynamic EDL schedule is updated at run-time from the static one. It takes into account the execution of the current ready tasks. It is described by means of the following two vectors:

• *Kt*, called dynamic deadline vector. *Kt* represents the instants *ki* from *t* in the current

• *Dt*, called dynamic idle time vector. *Dt* represents the lengths of the idle times that start at

Assume now that, given the task set T = {*T*1(3, 10, 10); *T*2(3, 6, 6)}, we want to compute idle times from instant *t* = 5 while tasks have been processed by EDF from 0 to *t*. The resulting schedule is depicted in Figure 5. Note that *f EDL* = 1 if the processor is idle at *t*, 0 otherwise.

*: simulated processing of periodic tasks according to EDL*

*: processing of periodic tasks according to EDF*

✲ ✻ ✻ ✻ ✻

✻ ✻ ✻ ✻ ✻ ✻

0 6 12 18 24 30

*k*<sup>0</sup> *k*<sup>1</sup> *k*<sup>2</sup> *k*<sup>3</sup> *k*<sup>4</sup> *k*<sup>5</sup> *k*<sup>6</sup>

Next, tasks are scheduled as late as possible according to EDL from time *t* = 5 to the end of the hyperperiod. Nonzero idle times resulting from the computation of vectors *Kt* and *Dt*

Chetto & Chetto (1989) showed that the EDL schedule computation can be efficiently used for improving the service of aperiodic tasks. By definition, soft aperiodic requests must not compromise the guarantees given for periodic tasks and should be completed as soon as possible. No acceptance test is performed for soft aperiodic requests; they are served on a best-effort basis within the computed idle times, the goal being to minimize their response times. Concerning hard aperiodic tasks, each task is subject to an acceptance-rejection test upon arrival. Hard aperiodic tasks can indeed easily be admitted or rejected on the basis of

In the next sections, we are first interested in using EDL to build a schedule on the red instances only so as to execute the blue instances as soon as possible in the remaining EDL idle times (see section 3.2 The RLP algorithm). In a second phase, EDL will allow us to derive a test for deciding on-line whether a blue instance can be accepted for execution or not (see

0 10 20 30

✲

✲

instants of *K*.

hyperperiod at which idle times occur.

✻

Fig. 5. EDL computation of dynamic idle times at time *t* = 5

appear at times *t* = 5, *t* = 6, *t* = 12 and *t* = 20.

the knowledge of idle times localization.

section 3.3 The RLP/T algorithm).

*: idle time* ✻ *: release time*

instants *ki* given by *Kt*.

*T*1(3, 10, 10)

*T*2(3, 6, 6)

*f EDL*

Fig. 3. A schedule produced by the RTO scheduling algorithm (*si* = 2)

Fig. 4. A schedule produced by the BWP scheduling algorithm (*si* = 2)

Figure 4 illustrates a BWP schedule for the task set T (see Table 1).

As can be seen, BWP increases the total number of task instances that complete successfully. Five deadlines of blue instances are missed at instants *t* = 24 (task *T*3), *t* = 36 (task *T*2), *t* = 48 (tasks *T*<sup>1</sup> and *T*3) and *t* = 72 (task *T*3). In contrast, all deadlines of blue instances are missed under RTO which represents a total of seven instances.
