Multicycle Polling Scheduling Algorithm - CiteSeerX

1 downloads 0 Views 90KB Size Report
scheduling will be defined in a more formal way, assuming the deadline for each .... Polling Scheduling problem based on hypothesis (2): the Rate Monotonic ...
Multicycle Polling Scheduling Algorithm for FieldBus Networks S.Cavalieri(1), A.Corsaro(2), S.Monforte(1) and G.Scapellato(1) (1)

University of Catania, Faculty of Engineering Institute of Informatic and Telecommunications Viale A.Doria, 6 95125 Catania (ITALY) (2)

Washington University, Computer Science Dept Campus Box 1045, St. Louis, MO 63130

Keywords: FieldBus Communication Network, Hard Real-Time Scheduling, Priority Scheduling Algorithm, Rate Monotonic Algorithm.

1

Multicycle Polling Scheduling Algorithm for FieldBus Networks S.Cavalieri(1), A.Corsaro(2), S.Monforte(1) and G.Scapellato(1) (1)

University of Catania, Faculty of Engineering Institute of Informatic and Telecommunications Viale A.Doria, 6 95125 Catania (ITALY) (2)

Washington University, Computer Science Dept Campus Box 1045, St. Louis, MO 63130

Abstract The paper deals with the scheduling of periodic information flow in FieldBus environment. The scheduling problem is defined from an analytical point of view, giving a brief survey of the most well-known solutions, and illustrating multicycle polling scheduling which is based on the hypothesis that all the production period of the periodic processes to be scheduled are harmonic. Although in some process control or manufacturing scenarios this hypothesis may be acceptable, there are many real industrial processes to which it cannot be applied. The aim of the paper is to make a contribution towards solving the scheduling problem. It essentially concerns extension of the theory on which multicycle polling scheduling is based to a much more realistic and general scenario, where the periods of all the processes to be scheduled have arbitrary values. We present a new formulation of multicycle polling scheduling, called extended multicycle polling scheduling, and demonstrate that it comprises the scenario currently considered in the literature. We then present an algorithmic solution to extended multicycle polling scheduling, demonstrating that it also coincides exactly with the solution given in the literature when the current restrictive hypotheses hold. Finally, some examples of scheduling further highlight the limits of the currently available algorithmic solution for multicycle polling scheduling and demonstrate the superiority of the solution proposed in the paper. 1.Introduction This paper deals with the problem of scheduling the information flow in communication systems for industrial applications such as process control and manufacturing. These systems are known as FieldBuses (Decotignie 1988). A FieldBus is a serial communication system interconnecting several field devices such as sensors, actuators and Programmable Logic Controllers (PLCs). The use of FieldBuses in industrial automation is quite recent: only a few years ago the communication system most commonly used was the 4-20 mA standard (Decotignie 1993). The advantages offered by a FieldBus, as compared with a traditional communication system based on the 4-20 mA standard, include simplified wiring, the sharing of resources and simplification of maintenance and documentation (Decotignie 1988). These account for the success and rapid spread of FieldBuses. 2

The use of FieldBuses has, however, introduced problems that were unknown to environments using the 4-20 mA standard, i.e. scheduling the time sequence for transmission of the information flow produced by the devices connected to a FieldBus. The need for scheduling is a consequence of the fact that a FieldBus is a serial communication system and thus requires a policy to manage the sequence in which the control devices transmit the information they produce. To meet the transmission requirements of each control device (e.g. deadlines for the delivery of information produced) transmission management has to be based on precedence and priority. The flow of information produced by the processes typical of process control and manufacturing is essentially of two kinds: periodic and asynchronous. A temperature sensor, for example, samples an analog signal and periodically produces temperature values. An alarm, on the other hand, is a variable the updating of which is unpredictable, i.e. asynchronous. Scheduling the transmission of both periodic and asynchronous information has to meet two types of constraints. For periodic processes it is generally necessary for each information produced to be transmitted before new information is produced. Let us again take the example of a temperature sensor sampling an analog value. If a value sampled is not transmitted before the next value is produced, it will be lost, with a consequent error in the reconstruction of the original analog signal. As far as an asynchronous information flow is concerned, it is important for all asynchronously produced information to be transmitted with a minimum delay. An alarm transmitted with an excessive delay, for example, would have disastrous effects. The scheduling of periodic information generally has very strict time constraints. Typical values for the periods in which information is produced are in the range of a few msecs. This means that all periodic information has to be transmitted in time intervals of the same order of magnitude. The delay times asynchronous traffic is allowed, on the other hand, may be as long as a few tens of msecs, or at times hundreds of msecs. It is therefore clear that scheduling a periodic information flow is much more critical than scheduling an asynchronous flow. This paper will therefore focus on the management of periodic information flows. Literature provides several approaches to the scheduling of periodic information in a FieldBus communication system. In the paper we will give a brief survey of these approaches. We will then focus on one of these scheduling strategies, known as multicycle polling scheduling. We will show that although this solution is efficient it is based on a rather restrictive hypothesis which is only applicable in certain process control and manufacturing scenarios. In many other applications, multicycle polling scheduling can only be applied if great simplifications are introduced, which may not be economical in terms of the communication bandwidth used. We then

3

propose an extension of multicycle polling scheduling, removing the current simplifying hypothesis and thus enabling the scheduling approach to be applied to real industrial control scenarios. To maintain the compatibility of the solution proposed with the existing one, it will be shown that, in the simplifying hypotheses provided by literature, our solution includes the existing one. We will conclude the paper by giving examples of scheduling, comparing the existing scheduling approach with ours. This comparison will highlight the limits of the former. It will be shown that in certain industrial process scenarios it fails to schedule the processes correctly, unlike the solution we propose. In other scenarios where it provides a valid solution, we will demonstrate the waste of bandwidth it involves, which is drastically reduced by applying the solution proposed in the paper.

2. Scheduling in a FieldBus Environment The aim of this section is to provide a definition of the problem of scheduling in the FieldBus environment being considered. The problem is based on certain hypotheses regarding both the kind of FieldBus system and the kind of processes producing the information flow to be scheduled. These hypotheses will be illustrated below and at the end of the section we will give a formal definition of scheduling based on them.

2.1. Types of FieldBus Communication Systems As said in the Introduction, in the last few years there has been a rapid development in FieldBus communication systems in the field of process control and manufacturing. Unlike other communication systems, FieldBuses are not regulated by a single set of norms so there are currently a large number of different kinds on the market, defined by European or international standards. The European standards are set by CENELEC and the documents produced are classified with the letters EN; examples of European standards are Profibus, standardised as EN 50170.2 (CENELEC EN50170.2 1996), WorldFIP, standardised as EN 50170.3 (CENELEC EN50170.3 1996), Interbus-S, standardised as EN 50254.2 (CENELEC EN50254.2 1999), and CAN, which is in the final stages of standardisation as prEN 50325 (CENELEC prEN50325 1999). On an international level, the International Electrotechnical Committee, or IEC, has recently drawn up a document known as the IEC 61158 FieldBus (IEC 61158.2 1992), (IEC 61158.3 1999), (IEC 61158.4 1999), (IEC 61158.5 1999), (IEC 61158.6 1999), (ISA dTR50.02 1998).

4

The FieldBuses currently available often have widely varying features and are at times incompatible with each other. They can, however, be divided into two large groups according to the physical channel access mode they contemplate. On the one hand we have centralised, or Master/Slave systems. In these communication systems, one or more devices (called Masters) authorise the other devices (Slaves) to transmit. This authorisation is generally based on polling. The Master keeps a list of Slaves to be polled cyclically. Each Slave polled by a Master occupies the bandwidth for the time it takes to transmit information. Once the transmission is over, the Master continues his cyclic polling. Each information to be transmitted therefore requires a time interval for the Master to send the polling request, followed by another time interval for the Slave to send the information requested. The other group of FieldBuses features distributed access: all connected devices occupy the same level in the hierarchy and have the same communication access rights. A typical example is the token passing mechanism used in the Profibus standard (CENELEC EN50170.2 1996), where access to the communication channel is provided by possessing a token which rotates cyclically between the devices connected to the FieldBus. It is not the aim of the paper to establish which strategy is the most efficient, and so no comparative analysis will be made between the two approaches to managing communication. We will confine the discussion to centralised-access FieldBuses. Examples of FieldBuses based on the Master/Slave approach are the IEC 61158 standard, Interbus-S, and WorldFIP. As said previously, only one device takes on the role of Master, controlling the information flow to be transmitted through the communication system. This occurs by polling the Slave stations and authorising transmission on request.

2.2. Types of Producer and Consumer Processes Connected with a FieldBus. As we have already pointed out, the flow of information exchanged through a FieldBus can be periodic or asynchronous. In this paper we will only consider the management of periodic information. We will consider producer processes that update variables periodically. The values of these variables are then used by the corresponding consumer processes. The variables are those typical of a manufacturing or process control environment, e.g. temperature or pressure. Producing the values of these variables corresponds to sampling analog signals (e.g. temperature, pressure level). Consumption of the values, on the other hand, corresponds to reconstruction of the original analog signals. The flow of information exchanged between a process periodically updating variables and a consumer process using them requires each value produced to be consumed before its deadline. The 5

deadline takes into account the time constraints of both the producer and consumer processes. It is defined as the length of each time interval between a generic production instant and the subsequent consumption instant. If these two coincide, the deadline will be taken as equal to the production period of the variable. The need to meet the deadline derives from the necessity for the consumer process to be able to reconstruct the analog signal sampled by the producer process correctly. If one or more values are not delivered to the consumer process within their deadline, the variable will be incorrectly reconstructed. The consequences for an industrial control system might be very serious, depending on the reconstruction error. Let us consider Fig.1. The arrows above the horizontal axis represent the instants at which the values of a generic variable are produced by a periodic producer process, while those under the axis show the instants at which the values are consumed by the consumer process. The figure shows the time interval that defines the deadline. In order to achieve a correct flow of information between the producer and consumer process, each information produced has to be transmitted by the FieldBus in the interval between the production and consumption instants, i.e. by the variable’s deadline. This is the aim of the scheduling that will be dealt with in the paper. In the following subsection the problem of scheduling will be defined in a more formal way, assuming the deadline for each periodic variable to coincide with the production period.

2.3. Polling Scheduling Problem dealt with in the Paper. Let us consider a generic set of τ1, τ2, τ3,..., τg groups of periodic process, which we will henceforward refer to as the task set. Each periodic process updates the values of one or more variables. This updating is characterised by a period. In addition, it is possible to define a deadline for each variable and the variables all have a certain length, expressed as a number of bits. An example is a temperature variable, whose binary code may require different lengths in bits according to the level of accuracy required and the range of values the variable can take. For each group τi of periodic processes we can identify four parameters: ni, Ti, Di, and Li, ∀ 1≤i≤g. The first, ni, represents the number of variables produced by the periodic processes belonging to the generic group τi. The second, Ti, represents the production period for each group of processes. The third, Di, represents the deadline for the variables belonging to group i. Finally, Li represents the number of bits required to code the variables belonging to the i-th group. As said previously, we will assume that the deadline Di coincides with the period Ti. We will also assume that all the values of Li, ∀ 1≤i≤g are the same, and equal to Ldata. This is the hypothesis generally made in literature, as it is a quite realistic one. If the values of Li are different, 6

the largest can be assumed as Ldata. The only disadvantage of this solution is a waste of bandwidth, which is only slight if it is considered that each periodic variable transmitted in a FieldBus environment occupies a few tens of bits. The problem of scheduling in a FieldBus environment based on Master/Slave access, assuming that Di=Ti, is to ensure that at least one transmission for each group τi and each of the ni variables belonging to the group will occur at least once in the production period Ti. As the scheduling of the transmission of the values of the variables belonging to the g groups is generally handled using a polling mechanism in a Master/Slave scheme, it is defined as a Polling Scheduling Problem. To transmit the values of the variables in the task set, polling-based access, as outlined in Section 2.1, requires a time interval given by the time it takes the Master to poll the process producing the variable and that required to transmit the value of the variable. As it has been assumed that Li=Ldata, ∀ 1≤i≤g, this time interval is the same for all the variables in the task set and will henceforward be defined as a time slot and indicated as trr. The duration of a time slot can be expressed by the following formula:

t rr =

L req + L data + Tret + Tlog bps

(1)

where: 1. 2. 3. 4. 5.

Lreq represents the size in bits of the polling request; Ldata represents the size in bits of the variable to be transmitted; bps represents the network bandwidth; Tret represents the time required by the Master to set the subsequent polling request; Tlog represents the processing time required for a Slave receiving a polling request to transmit the variable. Literature provides two different polling scheduling strategies, according to the ways in

which the Master handles the polling. They are called Monocycle and Multicycle Polling Scheduling. In the next section we will describe these two strategies and highlight the differences between them in terms of performance.

3.Monocycle versus Multicycle Polling Scheduling

Monocycle polling is the most common scheduling strategy used. It is, for example, the strategy contemplated in the FIP standard (French Association for Standardization 1990). In monocycle polling scheduling the Master uses a single cycle for the polling required for all the variables belonging to the g groups in the task set to be transmitted. We will refer to this 7

cycle as the polling cycle. In a polling cycle, the variables are polled using Time Division Multiplexing, reserving a time slot for the transmission of each variable in the task set. Let us consider the task set in Table 1, and assume that the time slot is 1/3 msec. Monocycle polling scheduling assumes that the polling cycle used by the Master to poll the 6 variables in the task set in Table 1 is equal to the shortest period, i.e. 2 msec. This choice is obviously linked to the need to guarantee that the most pressing deadlines will be met. 6 time slots are allocated for polling and transmission of the values of all 6 variables. It is clear that the transmission sequence thus determined will ensure that all the deadlines are met, assuming that they coincide with the production period. Fig.2 shows the transmission sequence for monocycle polling scheduling considering the task set in Table 1. The example highlights the simplicity of implementation of the monocycle polling scheduling strategy. It is also clear that the main disadvantage of this approach is represented by the poor exploitation of the available bandwidth, as the values of all the variables in the task set are transmitted in each polling cycle. In this way, some variables are polled more than once in the same production period. A solution that overcomes this limitation is known as multicycle polling scheduling. This scheduling strategy is based on the idea of differentiating between the cycles used by the Master to poll the periodic variables, on the basis of their period. Fig.3 shows a typical transmission sequence for multicycle polling scheduling, again with reference to the task set in Table 1. As can be seen, the Master uses three different cycles to poll the 6 variables. The values of the three cycles are exactly the same as the periods of the three groups of variables. By differentiating between the three cycles we save on bandwidth but still guarantee that all the deadlines for the 6 variables are met. Both Monocycle and Multicycle Polling Scheduling also allow the transmission of asynchronous information. Each polling cycle contains time intervals dedicated to the transmission of asynchronous information (again by means of polling). A polling cycle is generally divided into two portions: one entirely dedicated to polling periodic variables and the other reserved for the handling of the asynchronous information flow. The reason for choosing two separate windows is to minimise the cost of context switching between the transfer of periodic traffic and that of asynchronous traffic. Due to its efficiency in handling the available bandwidth, in the rest of the paper we will only deal with Multicycle Polling Scheduling.

8

4.Classical Solution to the Multicycle Polling Scheduling Problem

In Section 2.3 we gave a formal definition of the polling scheduling problem. The aim of this section is to describe how the polling scheduling problem can be solved using the multicycle polling illustrated in the previous section. Fig.3 gave an example of the polling sequence in each polling cycle. It is clearly necessary to find a strategy that will allow us to determine the correct polling sequence for any scheduling scenario. One of the best-known solutions to the multicycle polling scheduling problem is to be found in (Raja 1993). It is based on the hypothesis that all the periods of the periodic variables are harmonic, i.e. the following relation always holds:

∀ i, j : 1 ≤ i, j ≤ g and Ti ≥ T j ⇒ Ti = k ⋅ T j

k ∈ Ν (2)

Under hypothesis (2), the multicycle polling scheduling approach presented in (Raja 1993) consists of considering harmonic polling cycles. More specifically, there is a minimum cycle coinciding with the shortest period, called a primary cycle. If Tpc is the duration of the primary cycle, Tpc=min(T1, T2,…, Tg). The other cycles are called secondary cycles and coincide with the periods of the remaining groups and are thus multiples of the primary cycle. Each polling cycle is divided into time slots, and each primary cycle is divided into two time windows called Synchronous and Asynchronous windows. The former are dedicated to polling the periodic information flow and comprise NSmax slot times. The Asynchronous window is dedicated to the transmission of variables produced by asynchronous processes (again using the polling mechanism) and comprises NAmax slot times. Obviously the duration of the primary cycle is Tpc=(NSmax + NAmax)⋅trr.

4.1. Algorithmic Solutions

The solution to the multicycle polling scheduling problem presented in (Raja 1993) can be obtained both off-line and on-line. In (Raja 1993) and in this paper we consider the latter. Algorithms capable of solving the multicycle polling scheduling problem on-line have to be able to calculate the transmission sequence for the periodic variables while the system is evolving. These algorithms are said to be either static or dynamic, according to whether the length of the Synchronous Windows is constant or not. Here we will only deal with static algorithms. Algorithms meeting these requirements are Priority Algorithms, which implement a polling mechanism based on the attribution of appropriate priorities to the various tasks.

9

In (Raja 1993) two priority-based polling algorithms are presented to solve the Multicycle Polling Scheduling problem based on hypothesis (2): the Rate Monotonic Multicycle (RMM) and the Earliest Deadline First Multicycle (EDFM). They involve three basic steps: 1. Calculation of NSmax. This step essentially aims to analyse the schedulability of the task set given as input. The calculation of NSmax is a consequence of this analysis. If NSmax⋅ trr is less or equal to Tpc, the task set is schedulable. The aim of calculating NSmax also has to be that of maximising the amount of bandwidth dedicated to variables produced by asynchronous processes, i.e. to choose the lowest of the values that render the task set schedulable; 2. Calculation and assignment of priorities. Each group in the task set is assigned a priority on which the polling algorithm is based, Before the polling algorithm is executed, all the tasks are put in decreasing order of priority, i.e. in such a way that ∀i, j : 1 ≤ i < j ≤ g group τi has a higher priority than group τj; 3. Execution of the polling algorithm. This is the algorithm executed on-line which decides the transmission sequence for the periodic variables in each cycle (both primary and secondary). The polling algorithm is based on the priorities assigned previously and the fact that the tasks have been ordered by decreasing priority, i.e. group 1 has the highest priority. The algorithm can be summarised by the C-like program in Fig.4. As can be seen, in each primary cycle all the variables belonging to group 1 are polled. Once group 1 has been polled, if the value of NSmax allows, the highest-priority group with variables still to be transmitted is polled. All the variables in this group are polled if NSmax is wide enough; otherwise only a part of them are polled. In the former case, the algorithm goes on to poll another group; in the latter, it waits for a new Primary Cycle to start.

Here we will only deal with the RMM algorithm, which will be illustrated in the following subsection.

4.1.1.Rate Monotonic Multicycle Algorithm

In the Rate Monotonic Multicycle Algorithm the priority of each group is calculated in step 2 by associating the highest priority to the set with the shortest period and the lowest priority to the tasks with the longest period. More specifically, the three steps described above become: 1. Calculation of NSmax. This is calculated on the basis of the results presented in (Raja 1993) and will be shown in the following subsection;

10

2. Calculation and assignment of priorities. Each group in the task set is assigned a priority based on the group’s period, the highest priority corresponding to the shortest period. Before the polling algorithm is executed, all the are ordered in decreasing priority, or increasing period, order, in such a way that the following relation holds: ∀i, j : 1 ≤ i, j ≤ g and j ≤ i ⇒ T j ≤ Ti (3) 3. Execution of the polling algorithm, as described in Fig.4.

In the following subsection the hypotheses made in (Raja 1993) will be maintained but a new formula for step 1, i.e. calculation of NSmax, will be proposed, which improves the use of bandwidth for asynchronous traffic and yet guarantees the scheduling of the periodic variables.

A. Calculation of NSmax

The calculation of NSmax was determined in (Raja 1993), with reference to the RMM algorithm, assuming the simplifying hypothesis (2) to be valid. The value of NSmax is expressed in (Raja 1993) by: g n  N S max = ∑  i  i =1  Ti 

(4)

The result given by Raja and Noubir is dimensionally incorrect as NSmax is an undimensioned magnitude (number of slots reserved for the window dedicated to periodic traffic) whereas in (4) it is expressed in Hertz. The incorrect formulation given by (4) is clearly of a typographical nature. The correct value of NSmax can easily be obtained by going back through the calculation made by Raja and Noubir in (Raja 1993). Their approach is essentially based on the condition that a task set be schedulable, as established in (Lehoczky 1989)(Lehoczky 1992), which is valid if Di=Ti and (2) is verified: g c ∑ i ≤ 1 (5) i =1Ti

where ci represents the computing time for the i-th task which, in multicycle polling scheduling, is equal to ci=ni⋅trr. The correct value, instead of (4), is: g n  N S max = Tpc ⋅ ∑  i  (6) i =1  Ti 

As explained previously, the aim of multicycle polling scheduling is to determine a polling sequence that will guarantee both the schedulability of the task set and minimisation of the value of NSmax. It is therefore important to reduce the value given by (6) even further.

11

Below we present a different approach, which allows us to obtain a new formulation for NSmax. Let us consider the schedulability condition (5), which can be rewritten as: g c g n ⋅t ∑ i = ∑ i rr ≤ 1 (7) i =1 Ti i =1 Ti

The value 1 in the second member of (7) represents the bandwidth available for scheduling, normalised to 1. As the duration of the synchronous window for each primary cycle is equal to NSmax⋅trr, the available bandwidth can be expressed by: N S max ⋅ t rr (8) Tpc Substituting (8) for the unity in (7) we obtain a valid schedulability condition for the multicycle polling scheduling problem: g n ⋅t ⋅t N ∑ i rr ≤ S max rr (9) Tpc i =1 Ti

From (9) we get: g n N S max ≥ Tpc ⋅ ∑ i (10) i =1 Ti

which is met by the following value of NSmax: g n  N S max = Tpc ⋅  ∑ i  (11) i =1 Ti 

since, by the definition of the ceiling, we have:  g ni  g ni (12) ∑ ≥ ∑ i =1 Ti  i =1 Ti

Given the obvious relation: g n  g n g n  Tpc ⋅ ∑  i  ≥ Tpc ⋅  ∑ i  ≥ Tpc ⋅ ∑ i (13) i =1  Ti  i =1 Ti i =1 Ti 

it is proved that the choice of NSmax given by (11) instead of (6) leads to a saving in the amount of bandwidth occupied by periodic traffic but still guarantees the schedulability of the task set.

B. Example of Rate Monotonic Multicycle Polling Scheduling

Let us consider the task set in Table 2, where it is again assumed that the deadlines coincide with the periods and trr=0.2 msec. 12

With the Multicycle Polling Scheduling strategy, Tpc=2msec. By applying (6) we get:   3 1  5  N S max = 2 ⋅    +   +    = 2 ⋅ (2 + 1 + 1) = 8   2   4  8  

With (11), on the other hand, we get: 12 + 2 + 5  3 1 5 N S max = 2 ⋅  + +  = 2 ⋅   = 6 8  2 4 8

As trr=0.2 msec, both approaches ensure the schedulability of the task set, seeing that NSmax⋅trr