Data Consistency with Preemptive Scheduling. ETAS INTECRIO

Add to My manuals
178 Pages

advertisement

Data Consistency with Preemptive Scheduling. ETAS INTECRIO | Manualzz

ETAS The INTECRIO Components

External events (interrupts) and periodic activations with controlled variations require short response times. Preemptive scheduling can meet these requirements. The disadvantage of preemptive scheduling is higher memory capacity since it is necessary to secure the context of interrupted processes/RE and ensure data consistency.

Preemptive scheduling also offers flexibility for handling external events or interrupts . It is possible to assign an interrupt source to a priority level, thereby starting the task with a very fast response time. This mechanism is represented by the direct transition from the status inactive to running

(see Fig. 5-22 on page 92). The tasks called by the occurrence of interrupts and planned by

the interrupt controller are referred to as hardware tasks .

Preemptive and cooperative tasks have different priority ranges that do not overlap. Preemptive tasks always have a higher priority than cooperative tasks.

5.8.1.4

Data Consistency with Preemptive Scheduling

In preemptive scheduling, it is possible that a process or RE with low priority is interrupted by a process/RE with higher priority. If the interrupted process/RE reads a variable and the interrupting process/RE describes the same variable, inconsistencies may occur if the interruption occurs between to successive

read operations as illustrated in Fig. 5-25. The diagram shows what happens of

the program code is interrupted during the processing and no resource protection is implemented.

Priority x = 2

Task B p1

B

p2

B

x = -1

Task A p1

A if(x < 0) {y = -x}

p1

A

{y = -x}

y = 1 y = -2

Data inconsistency

Fig. 5-25 Data inconsistency

Time

Process p1

A

of task A calculates the absolute value of x : if (x<0)

{y = -x;} else

{y = x;}

Process p1

A

reads the input value -1 . The condition of the first line of the algorithm is met, so that the assignment y = -x is scheduled for execution. Before the assignment can be executed, process p1

A task B assigns x the value of 2 . If p1

A

is interrupted. Process p2

B

of

is taken up again after the end of task B, the algorithm uses the pending assignment y = -x and the new value x = 2 instead of x = -1 , i.e. p1

A

furnishes an incorrect result: |-1| ≠ 2 .

INTECRIO V4.7 - User’s Guide 94

ETAS The INTECRIO Components

This is merely a simple example to illustrate data inconsistency; however, in a real application, data inconsistency can lead to a system crash.

The correctness of the system therefore depends on the time sequence and the order of interruptions in the system. To avoid system and timing-dependent software errors, data consistency must be guaranteed.

NOTE

For the time between start and termination of a process P1 or RE R1, it must be ensured that all data stored in memory accessed by P1/R1 may change their value if and only if they are changed by P1/R1.

Messages: To solve the problem of data consistency, the messages concept

is supported by the crossbar (cf. section 3.5.5). These are protected global vari-

ables. The protection is achieved by working with copies of the global variables.

The system analyzes whether a copy is required and ensures an optimum data consistency scheme without detrimental effects on the core of the runtime.

While a process is being started, all input messages in its private area are copied for message copies. After the process is finished, all output messages that are located in the private area as copies, are copied into the global message

area. The operating principle of messages is represented in Fig. 5-26.

Priority msg x = -1 msg x = 2

Task B msg(1) x = -1 p1

B

p2

B

msg(1) x = -1

Task A p1

A if(x < 0)

p1

A

{y = -x}

y = 1

Time

Fig. 5-26 Handling of messages

At the start, process p1

A

of task A copies the incoming message msg to the private message copy msg(1) . All subsequent read operations to the message access this private copy. Although process p1

A

is interrupted by task B, which sets the value of msg from -1 to 2 , this change does not affect process p1

A

.

This ensures that process p1

A

works with the private copy throughout the entire execution time. This ensures the data consistency since the algorithm if (x<0)

{y = -x;} else

{y = x;} is correctly executed in any case.

INTECRIO V4.7 - User’s Guide 95

advertisement

Related manuals

Download PDF

advertisement

Table of contents