Integrating PFairness within a model based scheduling tool

Annie Choquet-Geniet LISI Université de Poitiers and ENSMA Téléport 2 1 avenue Clément Ader BP 40109 86961 Futuroscope Chasseneuil cedex France www.lisi.ensma.fr annie.geniet@univ-poitiers.fr Galle Skapin-Largeteau Xlim-SIC Université de Poitiers BP 30179 86962 Futuroscope Chasseneuil cedex France http://www.sic.sp2mi.univ-poitiers.fr/ glargeteau@sic.univ-poitiers.fr Abdoulaye Ouattara Université Polytechnique 01 BP 1091 Bobo-Dioulasso 01 Burkina Fasso


INTRODUCTION
A real-time application must satisfy the time constraints coming from the criticity of certain actions that allow them to interact with the environment of the monitored process.Additional qualitative contraints which insure a good quality of service can also be considered.If the strict time constraints are not satisfied, dysfunctions may occur, which can have unacceptable consequences (e.g.loss of human lives).If the qualitative constraints are not satisfied, the behaviour of the controlled process will have a lower quality.We are here interested in real-time applications dedicated to the control of processes, with strict time constraints, and regularity requirements in the execution.These requirements are captured by the PFairness property.A real-time application must thus be functionally as well as temporally validated.We focus here on the temporal validation, which relies on an appropriate scheduling policy, that can then be proved to respect all temporal constraints.Two approaches can be considered: the on-line method where a scheduling policy is implemented within the scheduler and the off-line method where a previously computed schedule is stored in a table and then used by a dispatcher.Classically, real- time applications dedicated to process control are modeled as a set of periodic tasks e.g.temperature acquisition in a nuclear station, robot's trajectory computation, processing of information provided by a synchronous link. . . .Tasks are preemptive, and can share critical resources.We assume that the application runs on a multiprocessor platform composed of m identical processors.We consider only global scheduling (figure 1): tasks can run at any time on any processor, they are never definitively assigned to a given processor.They may start on one processor and resume on another.We also assume that parallelism is forbidden: at any time, a task runs on at most one processor.
In such a context, it has been proven that there exists no optimal on-line strategy (12; 14) where a scheduling algorithm (or strategy) is said to be optimal if either it produces a feasible (or valid) schedule, i.e. a schedule such that all deadlines are met, or there exists no feasible schedule.Furthermore, since critical resources are used, the scheduling problem is NP-hard (1; 17).This motivates the choice of the off-line method.Most off-line strategies relies on branch-and-bound enumeration techniques.These approaches are generally model-driven.The task system is first modeled, then the schedulability analysis relies on exhaustive enumeration techniques.Following, if a valid schedule exists, it will be found.These approaches are thus more powerful than on-line strategies.This can be explained by the fact that scheduling decisions are made according to the instantaneous state of the application for online strategies meanwhile they are based on a global knowledge of the application for off-line scheduling.Another benefit of off-line methods is that additional qualitative criteria can be considered.
For example, we can find a valid schedule with minimal response times for some tasks, or a valid schedule where some tasks are regularly (or PFairly) processed.Approaches based on finite automata and on Petri nets can be found in the litterature (13; 16).We consider here an approach based on discrete geometry.Such an approach has a lower complexity than the former approaches, as well for the model generation as for the model analysis.In (15), we have defined a discrete geometrical model equivalent to the automata based model presented in (11).In this model, each task is associated with a 2D-discrete object that collects all the valid states of the task, i.e. all the states (cumulated processed execution time of the task, time) belonging to a valid schedule.The shape of this 2D-discrete object depends only on the time characteristics of the task.The execution of the task set is then modeled by a n+1-discrete object (where n is the number of tasks).This model is called Concurrency Model and is built using extrusion and intersection of the single task models.Ressource sharing is modeled using a nDdiscrete space, extruded following the time direction and then cut out from the concurrency model (see figure 5).We have proved in (15) that there exists a feasible schedule on a m-processor architecture if and only if there exists a m-connected path in the (n + 1)D-discrete model of the application.
Our aim is to use this model in order to include PFairness properties in the schedule selection step.For independent task systems, PFair strategies have been proposed.Moreover, if tasks are synchronous (they all are first released at the same time) with implicit deadline (deadlines are equal to periods), the algorithms PF, PD and PD 2 (4; 5; 2; 3) are optimal.But in our context, there exists no on-line PFair optimal strategies.We thus want to determine among the valid schedules produced by our off-line methodology which ones are PFair.For that aim, we first present a geometric characterisation of the PFairness, which is used to propose a method for the extraction of (partially) PFair schedules.Then, we propose a method in order to extract as PFair as possible schedules, when no PFair schedule exists.This method relies on PFairness benchmarks.The paper is organized as follows: in section 2, we introduce basic notions and notations for the realtime scheduling and the discrete modeling of realtime applications.In section 3, we present PFair scheduling and its geometrical modeling.And in section 4, we show how of our model can be used for a qualitative temporal analysis of a real-time application.

Basic notions of real-time scheduling
We consider multiprocessor systems composed of m identical processors.For any real x, x denotes the greatest integer less than or equal to x and x the smallest integer greater than or equal to x.
Each task is submitted to hard temporal constraints.We adopt the classical modeling of tasks.Each periodic task τ is characterized by four temporal parameters as described in figure 2: r is the first release date or offset; C the worst-case execution time; D the relative deadline, which corresponds to the maximal delay allowed between the release and the completion of any instance of the task; and P the period.In the sequel, we denote a task τ by < r, C, D, P >.Each task τ consists of an infinite set of instances (or jobs) τ k , released at times r + (k − 1) × P , with k ∈ N * .We assume that temporal parameters are known and determinist.We denote H the hyperperiod of the system defined as H = lcm(P 1 , P 2 , . . ., P n ).The processor's utilisation factor characterises the processor workload due to the application.It is defined by U = n i=1 Ci Pi .If U > m (m being the number of processors), the system is over-loaded and temporal faults cannot be avoided (6).In the sequel, we suppose that the utilisation factor is lower than m.In the further, slot t (t ∈ N) denotes the time interval [t, t + 1).A task is said to be scheduled at time t when one processor processes it during slot t.A schedule is defined by S : then (m − k) processor idle time units occur at time t, i.e. (m − k) processors remain idle during slot t.The function S τ describes the behaviour of a task and is defined by For any times t and t , and for any task τ , we define W τ (t, t ) as the processed execution time for task τ between time t and time t .
We have thus  A task τ is modeled by an object Ω(τ ) of a 2D space: the (processed execution time, time) space.The shape of this 2D-discrete object depends on the temporal parameters of the task (see figure 3).

Geometric model for real-time system behaviours
The model for a task τ =< r, C, D, P > is formally defined as : the remaining time until the next deadline is greater than or equal to the remaining processing time of the pending instance Then to model the complete application Γ = (τ i ) i∈ [1,n] , we introduce the set Figure 4 presents the model obtained for an application composed of two tasks.Finaly, concurrency is considered.The final model is deduced from the previous one using extrusion and intersection operations (see figure 5).Resource sharing between tasks τ i and τ j is modeled by a surface in the (x i , x j ) plan which is then extruded following time direction.The result is finaly cut out from Ω(Γ) to obtain Ω(Γ, R).
We can then deduce the feasibility of the application for a given architecture.If we consider a platform of m identical processors, the existence of a feasible schedule relies on the connectivity properties of the model Ω(Γ, R).Two points (x 1 , . . ., x n , t) and (x 1 , . . ., x n , t + 1) are said m-neighbours if ∀i ∈ A m-connected path of length T is a set of T mneighbour points.We finaly have the following result: Proposition 1 There exists a feasible schedule for a platform of m identical processors iff there exists a m-connected path in the model Ω(Γ, R).A complete definition of the geometric model can be found in (15).

DISCRETE MODELING OF PFAIRNESS
We want to take a further quality criterion into account: the regularity of execution for (some of) the tasks of the system.This can be useful for some kind of applications, e.g.multimedia applications, to insure a process' behaviour of good quality.This can also be helpful for an efficient aperiodic task management.We first introduce the notion of PFairness.Then, we present the way PFairness is taken into account in our model.In a first time, we consider synchronous tasks with implicit deadlines (∀τ, r = 0 and D = P ).Then we relax the constraint r = 0 and model asynchronous tasks.Next we consider systems with constrained deadlines (D ≤ P ) and finally we take concurrency and critical resource sharing into account.

PFair scheduling algorithm
PFair scheduling strategies have been proposed in the general multiprocessor context, for which they are very efficient.The basic idea is that each task is processed at "regular rate".This means that at each time t (t ∈ N), the processed execution time W τ (0, t) is proportional to t, with a proportionality coefficient equal to u = C P .But, since the processed execution time at time t must be integer, u × t is approximated by either u × t or u × t .This is formally expressed by the following definition: A schedule is PFair for a task τ iff we have: A schedule is PFair if it is PFair for each task τ of Γ. Figure 7 illustrates PFairness.For any task τ , the broken line W tau must remain strictly between both limit lines Ideal − = u × t − 1 and Ideal + = u × t + 1.At any time t, a task τ = < r, C, D, P > is said to be: It has been processed a little bit more than in the ideal case.We have: S τ (j) < 0.
• punctual if it has been processed for exactly u × t slots.We have: S τ (j) = 0.
• behind if W τ (0, t) is under the ideal line Ideal(t) = u × t.It has been processed a little bit less than in the ideal case.We have: PFair strategies (they are PFair for each task) follow the global frame described below.
1.The task set is partitioned into three sets.
• the Urgent set collects all the behind tasks which would be too late (under the lower bound) if they were not processed at time t.These tasks must be processed at time t, else the PFairness condition would be violated.
• the Tnegru set collects the ahead tasks which would be too in advance (over the upper bound) if they were processed at time t.These tasks must not be processed at time t, else the PFairness condition would be violated.
• the Contending set collects the other tasks: the PFairness is violated neither if they are processed nor if they are not.
Figure 8 shows examples of PFair and non PFair behaviours, and illustrates the different status of a task.Several PFair versions have been proposed in the litterature (PF, PD and P D 2 (4; 5; 2; 3)).These algorihms differ in the way they select the tasks to process among the contending tasks.These scheduling strategies are very efficient, as stated in theorem 2.
Theorem 2 (4) The scheduling algorithms PF, PD and P D 2 are optimal for systems of periodic synchronous independent tasks with implicit deadlines (deadlines are equal to periods) in multiprocessor context.Moreover, the system is feasible if and only if U ≤ m where m is the number of processors.
1 |A| denotes the cardinality of set A.

Extensions of the PFairness
The notion of Pfairness is defined in the context of synchronous tasks with implicit deadlines.In (3; 10), asynchronous systems are considered, where asynchronism means that some of the first task slots do not take place.But the first instance of any task is still assumed to be released at time 0. In (2), sporadic tasks are considered: periods correspond only to the minimum elapsed time between two consecutive releases.We consider here a different notion of asynchronism: the first release times of the different tasks, i.e. the release time of the first task slot, are no more assumed to be equal.But all the task slots are assumed to occur, and their release times cannot be chosen arbitrarily.To shift a task may be useful e.g. in order to take some precedence relations into account.Furthermore, requiring tasks to have periods equal to deadlines restricts the application of PFairness in practice.We thus consider task systems where tasks may have non zero first release times, and may have constrained deadines (D ≤ P ).
To define PFairness in this enlarged context, we first consider the ideal case: in an ideal fair schedule, a task τ must have received at time t, ω τ (t) processor time units (see figure 9) where ω τ (t) is defined by: where k = t P represents the number of already completed instances of the task.The condition (1) corresponds to the idleness of the task before its first release, the condition (2) corresponds to the classical PFairness notion, and the part (3) expresses the idleness between each deadline, and the next release.A schedule S is then PFair for a task τ iff We can notice that during the idle periods, the task must be punctual, because the only integer points between both limit lines are those located on the ideal line.

PFair geometric modeling
Our aim is to include PFairness properties in the geometric model.The final goal is to determine the set of the PFair schedules for a given application which cannot be PFairly scheduled by the classical  In such context, the PFair algorithms are not optimal.
We define the PFair geometric model for a task τ = < r, C, D, P > as the set of the states belonging to a PFair schedule.We call these states the PFair states.

Definition 3
The PFair geometric model of a task τ is the set: ) for the task τ = < 3, 3, 7, 11 > where p stands for "the task is processed" and for "the task remains idle".In the following, we define this set on a more geometrical way.We assume that the first release time of a task τ is equal to 0, and that its relative deadline is equal to its period.The discrete model of the PFair behaviours of the task τ is composed of all the states that the task can reach if it is PFairly processed.This set consists of all the discrete points that are close enough (at a distance lower than 1) to the line x = (C/P )t.

Processed execution time
Since PFair states belong to feasible schedules (4), we also have the following property:

Asynchronous task systems with implicit deadlines.
We assume that r > 0 and D = P .In this context, a task cannot be processed before its first release.Therefore, the only states available before this time are those with x = 0.After release, the execution curve must remain close to the line x = C P × t + r.

Asynchronous task systems with constrained deadlines.
We consider now the complete task set Γ = {τ 1 , τ 2 , . . ., τ n }.The PFair geometric model of the application is defined by: Definition 7 The set of discrete PFair states for the application Γ is Resource sharing.We consider a task set Γ = {τ 1 , τ 2 , , τ n }.Let R be a critical resource, and I R be such that τ i uses R iff i ∈ I R .We must eliminate from the model all the invalide states.These states correspond to: 1.The joint use by two tasks of a critical resource.

Isolated states, which have no predecessor.
They thus don't belong to a PFair schedule.
3. Dumb states, which have no successor in the model.They neither belong to a PFair schedule.
We first consider point 1.We remove all the points corresponding to a violation of the mutual exclusion rules.For a given resource R, these R-invalide points are collected in a set Ω(R).Then, we remove iteratively isolated and dumb points, until a fixed point is reached.For simplicity reasons, we assume that each task using a resource R contains only one critical section for R. The definitions can then be easily extended to several critical sections.If a task τ uses a resource R, we denote pre τ (R) (resp.post τ (R)) the processing time until the begining (resp.the end) of the critical section.The critical section lasts thus post τ (R)−pre τ (R).We define then the set of the R-invalide points by: Definition 8 The set of the R-invalide states is defined as: The set of the discrete resource-valid points is the set: And the set of the discrete resource-valid points is the set: where Res is the set of all the critical resources used by the application.
The inequalities express the fact that both pending instances of the tasks τ j1 and τ j2 are in their critical section.
) is the number of already completed instances of τ j1 (resp.τ j2 ).We then remove isolated and dumb points: a point (x 1 , . . ., x n , t) is isolated if there in no point (x 1 , . . ., x n , t − 1) with x i = x i or x i = x i − 1 and a point (x 1 , . . ., x n , t) is dumb if there is no point (x 1 , . . ., x n , t + 1) with x i = x i or x i = x i + 1.We can note that an isolated point is the n-neighbour of no point, and a dumb point has no n-neighbour.For terminaison reason, we only consider the model over a finite time interval.If tasks are synchronous, cyclicity results show that the construction can be restricted to the time interval [0, H], where H is the hyperperiod.If asynchronous systems are considered, we will restrict ourselves to the time interval [0, max([r i ] i 1...n ) + 2 * H].In such a model, the number of points is finite, thus, we are insured to get a fixed-point when we iterate the removing process.We thus finaly get a model denoted by M (Γ, T ) if we consider the time interval [0, T ].

SYSTEM ANALYSIS USING THE GEOMETRIC MODEL
In the previous section, we have proposed a model M (Γ, T ) which can take temporal validity, mutual exclusion properties and PFairness into account.We present now some examples of the use of the model for the sake of temporal and qualitative analysis of a real-time application.The general frame of our analysis consists in the use of the model to compute the set of feasible schedules with additional PFairness properties.

Global PFairness
Firstly, we can use the model in order to generate all the PFair behaviours.We recall that in our context: asynchronous systems with constrained deadlines and critical resources, there exists no on-line optimal strategy.We use the geometric model to determine whether there exists some PFair schedules for the application, for a given architecture.We finally have the following result: Proposition 9 There exists a PFair schedule for a platform of m identical processors on the time interval [0, T ] iff there exists a m-connected path in the model M (Γ, T ).

Partial Pfairness
Considering global PFairness may be too restricting.First, it can be useful to insure processing regularity for some tasks, but not for all.And requiring PFairness for all the tasks may lead to unfeasibility, due e.g. to the constaints induced by the resource management.When PFair strategies (PF, PD or PD 2 ) are considered, PFairness requirements are globally applied.Our methodology enables to refine the analysis, and to restrict the PFairness requirements to a subset of tasks.This leads to more flexible scheduling.A direct application is the possibility to combine an off-line method to schedule the periodic tasks with an efficient on-line algorithm for the integration of aperiodic tasks with strict deadlines.We have proposed in (7) an online acceptation algorithm which relies on a PFair distribution of processor idle times.The presented methodology uses a PFair scheduling algorithm to schedule the periodic application.We make the assumption that the tasks are synchronous, independent, with implicit deadlines, and that m − 1 < U < m.In such a case, the processors remain idle for H(m − U ) processor time units.A further task, the idle task is added to the system.It is defined by τ 0 =< 0, H(m − U ), H, H >. The extended application is then globally scheduled by means of a PFair strategy.It follows that a PFair distribution of the processor idle times is guarantied.Here, we can enlarged the acceptation routine to applications composed of non independent periodic tasks which may be asynchronous and have constrained deadlines.We then add the idle task to the system, and we require the idle task, and only it, to be PFairly processed.The acceptation routine for aperiodic trafic can then be used even if the other periodic tasks are not PFairly scheduled.

Non PFairly feasible systems
For some applications, because of the use of critical resources, it is definitively not possible to find PFair schedules.This means that M (Γ, T ) contains no mconnected paths.In this case, it can nevertheless be interesting, for quality reasons, to find a schedule which is as fair as possible, provided Ω(Γ, Res) contains m-connected paths.Here again, this requirement can be reduced to a subset of tasks.For that purpose, we use a PFairness benchmark.In (8), we have proposed several PFairness measures for synchronous task systems, with implicit deadlines.We enlarge the most promising one to our context.For synchronous tasks with implicit deadlines, the on-line PFair strategies (PF, PD and PD 2 ) rely on the decomposition of each task τ into unitary subtasks τ j (j > 0).Each subtasks τ j has a pseudo-release time and a pseudo-deadline defined by: r j = j−1 u(τ ) et d j = j u(τ ) .The time interval [r j , d j ) is the feasability window of the substask.The task τ is PFairly processed iff each of its subtask is scheduled within its feasability window.The PFairness measure that we propose depends on the distance of the execution time of the subtasks to their feasability windows.This distance is equal to 0 if the execution is PFair.We must enlarge the definition of the measure to asynchronous task sets with constrained deadlines.We first adapt the notion of feasability window.In our context, the feasability window of the subtask τ j is defined by: [r j , d j ) with r j = r + k * is the instance number of the task τ .We define then for a schedule S the distance between a subtask and its feasibility window by: dist(τ j , S) = M ax{0, r j − b j , e j − d j } where b j is the begining date of the subtask τ j in the schedule S and e j is its terminaison date (e j = b j + 1).We can see in figure 14 an execution of the two first instances of a task τ =< 2, 3, 5, 8 >, thus the 6 th first subtasks.We can see within each subtask its distance to its feasability window, which is equal to 0 for the subtasks τ 1 , τ 2 , τ 4 and τ 5 , and equal to 1 for the subtasks τ 3 (it is processed one time unit too early) and τ 6 (it is processed one time unit too late).The PFairness measure for a given  • nbr(τ, T ) is the number of complete periods within [0, T ].We have nbr(τ, T ) = T −r P

CONCLUSION
PFair scheduling is a very powerful strategy for real-time scheduling in multiprocessor context.It has been proved to be optimal for synchronous, independent task systems, with implicit deadlines.It could thus be of interest to use it for larger context.Furthermore, it can be interesting to enforce PFair behaviours for some kind of applications.
PFair constraints can also be restricted to a subset of tasks.Besides, the discrete geometrical approach is really effective to decide feasability and finding feasible schedules.We have here coupled both notions.We have presented the geometrical characterisation of PFair behaviours of a realtime application.We have then explained how to take resource management constraints into account in our model.Finally, we have presented three applications of our modeling methodology for the analysis of a real-time application with PFairness requirements.

Figure 2 :
Figure 2: Temporal modeling of a real time periodic task

Figure 4 :
Figure 4: Geometric model for two tasks

Figure 5 :
Figure 5: Integration of the concurrency

Figure 6 :
Figure 6: Neighborhood of the point P

Figure 7 :
Figure 7: PFair execution of a task: the execution curve must be located between both dotted lines

Figure 8 :
Figure 8: (a) a PFair execution and (b) a non PFair execution -Different status of the task

Figure 10
Figure 10 presents the PFair schedule ( p p p) for the task τ = < 3, 3, 7, 11 > where p stands for "the task is processed" and for "the task remains idle".In the following, we define this set on a more geometrical way.

Figure 13 :Definition 6
Figure 13: Geometric model and PFair-state set V (τ ) for the task < 3, 3, 7, 11 > We relax our last constraint and consider a task with a constrained deadline, i.e. such that D ≤ P .We must model the PFairness condition given in section 3.2.Each instance τ k of the task must complete its execution before its deadline d k = r + (k − 1)P + D and must be idle between d k and the release time r k+1 = r + kP of the next instance.The task must be processed during C slots between r k = r + (k − 1)P and d k .So the execution rate is here equal to CH = C D , and the task is idle before r and between d k and r k+1 for each k ≥ 1.We thus have: Definition 6 The set of discrete PFair states for a task τ = < r = 0, C, D ≤ P, P > is defined by:

Figure 14 :
Figure 14: Distance beetwen a subtask and its feasability windowschedule, a given task and a time interval [0, T ] is the quotient of the cumulated distances of each subtask whose feasability interval in included within [0, T ), and of the worst possible value.The worst value is obtained when each instance τ k is processed either at the beginning or at the end of its execution window [r + (k − 1)P, r + (k − 1)P + D].Formally, we have: