84
GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 305 FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12 UNIVERSIDAD DE CANTABRIA 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks 9.4 End-to-end deadlines 9.5 Transactional model of real-time systems 9.6 Analysis of end-to-end deadlines 9.7 Handling task suspension 9.8 Multiprocessor synchronization

9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 305FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9. Distributed and multiprocessor systems9.1 Introduction9.2 Message passing systems9.3 Real-time networks9.4 End-to-end deadlines9.5 Transactional model of real-time systems9.6 Analysis of end-to-end deadlines9.7 Handling task suspension9.8 Multiprocessor synchronization

Page 2: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 306FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Page 3: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 307FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.1 IntroductionAnalysis in a distributed environment:• end-to-end deadlines• handling suspension

Multiprocessor synchronization

Priority Inversion in the Client/Server Approach

Page 4: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 308FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

These are the issues related to multiprocessor and distributed systems, that we want to discuss:• Analysis in a distributed environment. We want to establish some basic concepts that will allow us to

analyze a multiprocessor system using the techniques shown in this tutorial. In particular, we will focus on:- Analyzing end-to-end deadlines- Handling task suspension

• Multiprocessor synchronization. We will show a new kind of priority inversion that appears in shared memory multiprocessors, called remote blocking. We will also provide solutions to avoid this negative effect.

• Priority Inversion in the Client/Server Approach. The client/server approach is a very popular paradigm used in distributed systems. However, priority inversions may arise that are important for real-time systems. A solution to this problem is discussed here.

Page 5: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 309FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis in a Distributed Environment

CPU-1 CPU-2

CPU-3

LAN

CPU-4

LAN

Backplane Bus

controller

Page 6: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 310FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

Multiprocessor or distributed systems are different from the conventional uniprocessor systems that we have used until now in this tutorial, because there are multiple resources that can be used simultaneously, such as multiple CPUs, LANs, Backplane Buses, etc. In a distributed environment, many of the events have responses that are executed in several resources. The analysis in one resource influences the other. For example:

• A chain of responses: An event arrives to one CPU, which processes it; after processing, a message is sent over a LAN; once this message arrives to the destination, another task is activated in a second CPU. We have a chain of three responses, each executed in a different resource.

• A remote procedure call: A server task runs in CPU-1 and accepts requests coming from a LAN. A client task is activated by an event and runs in CPU-2. In the middle of its execution it sends a request to the server task, using the LAN, and suspends itself waiting for a response. When the response arrives from the LAN, the task resumes its execution. We have a chain of five responses in this case (client-1, request message, server, response message, and client-2).

The special characteristics of distributed environments introduce new issues such as:• end-to-end deadlines• task suspension• task allocation and prioritization

Page 7: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 311FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.2 Message passing systemsAsynchronous message passing

task 1

task 3

task 2

CPU-1

task 4

task 5

CPU-1

Real-Time Network

Page 8: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 312FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Message passing systems (cont’d)Remote procedure calls

task 1

task 3

task 2

CPU-1

task 4

task 5

CPU-1

Real-Time Network

Page 9: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 313FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.3 Real-time networksVery few networks guarantee real-time response• many protocols are based on collisions• no priorities or deadlines in the protocols

Some solutions• CAN bus• Priority-based token passing (e.g., RT-EP)• Time-division multiplexed access• Point to point networks• ATM

We will assume a priority-based network

Page 10: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 314FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Page 11: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 315FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.4 End-to-End DeadlinesIt is possible to add response times in different resources to find out the worst-case end-to-end response time

The portions of the distributed response after the first are not initiated periodically. We can use two approaches:• Analyze the effect of jitter

- the analysis is complex, because jitter in one resource affects response times in other resources, and viceversa

• Or eliminate jitter by using purely periodic activation or a sporadic server

The analysis of the network is done like the analysis in a CPU, but:• the scheduling policy is usually different than in the CPUs

Page 12: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 316FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

The main problem that appears in a distributed system when a response is comprised of portions that run in different resources, is that all portions except the first are not activated periodically. Since each portion is activated when its predecessor has finished, it has jitter in its activation, which influences the response time of lower priority tasks. We can use two approaches to handle jitter:

• Analyze the effect that jitter has on the schedulability of lower priority responses. We must take into account that the jitter in one resource influences the response times in that resource, which in turn influences the jitter in other resources. However, since the effect of increasing the jitter can only increase the response times, we can apply the schedulability equations iteratively, first assuming that there is no jitter, and then using the jitter from the previous iteration, until we reach a stable result.

• The second approach consists of eliminating jitter by activating each portion of the response at periodic intervals. These intervals are calculated so that when one portion is started, there is guarantee that the previous portion had already completed. The same effect can be used by scheduling each portion of the response with a sporadic server, that will guarantee that the effects on lower priority tasks are not worse than those of an equivalent periodic task.

The schedulability of LANs is usually determined in the same way as in a CPU: messages are treated like tasks, and message transmission times are like task execution times. However, we must be careful, because most LANs do not operate like CPUs, in a priority preemptive way. The analysis must take into account the scheduling policy of the LAN.

Page 13: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 317FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Release jitter in distributed systemsIn the example below, actions a2,a3 and a5,a6,a7,a8 have jitter, even if a1 and a4 are purely periodic:

CPU-1

Network

CPU-2

a1a5

a3a8

a4 a7

a6

a2

a1a5

a3a8

a4 a7

a6

a2

Page 14: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 318FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

The problemRelease jitter in one resource depends on the response times in other resources

Response times depend on release jitter

Page 15: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 319FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.5 Transactional model of real-time systems

Network CPU-2CPU-1

Linear Action:

Linear Response to an Event:

ajej-1,j ej,j+1 Tj-1,j = Tj = Tj,j+1

a1e1 a2

e1,2 a3e2,3

d2D2

ED3

Actione1 External

evente1,2 Internal

event

Page 16: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 320FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Example

GUI

TrajectoryPlanner

Reporter

CommandManager

ServoControl

DataSender

CommandMessage

StatusMessage

Teleoperation Station

Ethernet

Local Controller

1sec

50ms5ms

NetworkRMT:Teleoperated Robot

Page 17: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 321FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Networks

Network

Packet_Based_Network

Transmission_KindThroughputMax_Packet_SizeMin_Packet_SizeMax_Blocking

Driver0..* List_of_Drivers

Page 18: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 322FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Network Drivers

Driver

Packet_Driver

Character_Packet_Driver

RTEP_Packet_Driver

Page 19: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 323FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Network drivers (cont’d)

Packet_Driver

Character_Packet_Driver

Character_Transmission_TimeScheduling_Server

Simple_Operation

Packet_Send-Operation

Packet_Receive-Operation

Packet_-Server

Character_Server

Character_Send_OperationCharacter_Receive_Operation

1

1

1 1

11

Message_PartitioningRTA_Overhead_Model

Page 20: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 324FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Network drivers (cont’d)

Packet_Driver RTEP_Packet_Driver

Number_Of_Stations

Scheduling_Server

Simple_Operation

Packet_Send-Operation

Packet_Receive-Operation

Packet_-Server

Packet_Interrupt-

1 1

11

Message_PartitioningRTA_Overhead_Model Token_Delay

Failure_TimeoutToken_Transmission_RetriesPacket_Transmission_Retries

Packet_ISR_Operation1

_Server

Token_Check_OperationToken_Manage_OperationPacket_Discard_OperationToken_Retransmission_OperationPacket_Retransmission_Operation

11111

Page 21: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 325FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Processing resources, schedulers, drivers, and timers

Page 22: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 326FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Scheduling Policies

Scheduling_Policy

Fixed_Priority

EDF

Worst_Context_SwitchAvg_Context_SwitchBest_Context_Switch

Max_PriorityMin_Priority

FP_Packet_Based

Max_PriorityMin_PriorityWorst_Context_Switch

Avg_Context_SwitchBest_Context_Switch

Packet_Overhead_Max_SizePacket_Overhead_Avg_SizePacket_Overhead_Best_Size

Page 23: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 327FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.6 Analysis of End-to-End DeadlinesThe analysis can be done in two different ways:• Holistic analysis: use the schedulability analysis for single

processor systems, as if all resources were independent:- Jitter depends on response times- Response times depend on jitter- Because the dependency of the response time on jitter is

monotonic, we can start with zero jitter and then iterate over the analysis until a stable solution is achieved

- This analysis is pessimistic• Using task offsets:

- More complex analysis- Much less pessimistic

Page 24: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 328FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

The analysis can be done in two different ways:• Using the schedulability analysis for single processor systems, as if all resources were independent.

The problem with this analysis is that jitter depends on response times, and the response times in turn depend on jitter. Because the dependency of the response time on jitter is monotonic, we can start with zero jitter and then iterate over the analysis until a stable solution is achieved. This analysis is pessimistic, because we are assuming that tasks encounter a critical instant in all CPUs and networks, but this may not be possible in practice because the execution of tasks is not independent.

Using task offsets:• This is a much more complex analysis, that takes into account the interactions among tasks through

the mechanism of considering task offsets. The results of this analysis are much less pessimistic than with the assumption of independent tasks.

Page 25: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 329FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Holistic analysis techniqueMainly developed at the University of York

Each resource is analyzed separately (CPU’s and communication networks):• all activations after the first have “jitter”• jitter in one action is considered equal to the worst-case

response time of the previous actions• analysis in one resource affects response times in other

resources• the analysis is repeated iteratively, until a stable solution is

achieved• the method converges because of the monotonic relation

between jitters and response times

Page 26: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 330FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis in the distributed system

Assumption: Ji = Ri-Rbi , Rb

i = best-case response time=0

algorithm WCRT isbegininitialize jitter terms to zeroloopcalculate worst-case response times;calculate new jitters, equal to responsetimes of preceding actions

exit when not schedulable or no variation since last iteration;

end loop;end WCRT

Page 27: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 331FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Pessimism in holistic analysisHolistic analysis technique assumes independent task activations in each resource

Task-5

Task-1

task21

Task-4

Task-3

CPU-1 CPU-2

Serial Line

m1

m2

task22Task-2

Page 28: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 332FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Independent task analysisExecution timeline for task22 in previous example:

Response time for task-2:• includes times for task21, m1, task-4, m2 and task22• total is 270

task-1

task21

task22

Page 29: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 333FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Using offsets to reduce pessimismExecution timeline for analysis of task-2:

task-1

task-2

serial

task-3

task-4

line

t=145

Page 30: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 334FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Objectives of the offset-based techniquesTo reduce the pessimism of the worst-case analysis in multiprocessor and distributed systems:• by considering offsets in the analysis,• offsets can be larger than task periods;

- this is important if deadlines > task periods• offsets can be static or dynamic:

- offsets are dynamic in distributed systems- also in tasks that suspend themselves

This enhancement comes “for free”, as there is no change to the application,• although better results can be obtained if best-case execution

times are measured

Page 31: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 335FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

System model with offsets

Γ1

Γ2

Γn

T1 T1

τ21 τ22

R12R11

Φ11 Φ12T2

Φ21Φ22

TnRn3

Rn1

Rn2

Φn1 Φn2 Φn3

In addition, each taskmay have jitter

Page 32: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 336FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis with offsetsDeveloped by Tindell, at the University of York:• The exact analysis is intractable• An upper-bound approximation provides good results (equal to

exact analysis in 93% of tested cases)

Main limitations:• Offsets are static:

- not applicable to general distributed transactions• Offsets are less than the task periods:

- for distributed systems, deadlines would need to be smaller than or equal to the task periods

Extended by Palencia (1998) to address these limitations

Page 33: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 337FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Scenarios for calculating the worst-case contribution of τij

Titc

Φij Φij Φij Φij

Ji

Titc

Φij Φij Φij Φij

Ji

Scenario 1

Scenario 2

Page 34: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 338FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Exact analysis with static offsetsContribution of task τij to the response time of lower priority tasks:• Set 0: activations that occur before the critical instant and that

cannot occur inside the busy period• Set 1: activations that occur before or at the critical instant, and

that may occur inside the busy period- Theorem 1: worst-case when they all occur at the critical instant- Theorem 2: worst-case when the first one experienced its

maximum jitter• Set 2:activations that occur after the critical instant

- Theorem 1: worst-case when they have zero jitter

Page 35: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 339FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Upper bound approximation for worst-case analysisExact analysis is intractable:• The task that generates the worst-case contribution of a given

transaction is unknown.• The analysis has to check all possible combinations of tasks

Tindell developed an upper bound approximation:• For each transaction we consider a function that is the maximum

of all the worst-case contributions considering each of the tasks of the transaction to be initiating the critical instant

• This technique is pessimistic, but polynomial• In 93% of the tested cases, the response times were exact

Page 36: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 340FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis with dynamic offsetsIn many systems the offset may be dynamic:

Example: task with a suspending operation

Φij Φij min, Φij max,,[ ]∈

task1

diskread

S ∈ [Smin,Smax]

Φ12 ∈ [Rbi1+Smin, Ri1+Smax]

task11 task12

Ri1

Page 37: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 341FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis with dynamic offsets (cont’d)Dynamic offsets can be modeled with static offsets and jitter:• Equivalent offset:

• Equivalent jitter:

The problem is that now offsets depend on response times, and response times depend on offsets• The solution is to apply the analysis iteratively, starting with

response times = zero, until a stable solution is achieved• We call this algorithm WCDO

Φ'ij Φij min,=

J'ij Jij Φij max, Φij min,–( )+=

Page 38: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 342FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis of multiprocessor and distributed systems

Dynamic offsets in distributed transactions can also be modeled with static offsets and jitter:• Equivalent offset:

• Equivalent jitter:

τi1 τi3 τi5τi4τi2

Distributed transaction Γi

Φ'ij Φij min, Rij 1–b= =

J'ij Jij Φij max, Φij min,–( )+ Rij 1– Rij 1–b–= =

Page 39: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 343FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Comparison with holistic analysis: 1 processor

Analysis for: 1 processor 10 transactions 10 tasks per transaction

1

1,5

2

2,5

3

3,5

4

4,5

5

0 10 20 30 40 50 60 70 80 90

% Utilization

Rin

dep/R

WC

DO

Tmax/Tmin = 10Tmax/Tmin = 100Tmax/Tmin=1000

Page 40: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 344FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Comparison with four processors, and best-case=0

Analysis for: 4 processors 10 transactions 12 tasks per transaction best case = 0

1

1,05

1,1

1,15

1,2

1,25

1,3

1,35

1,4

1,45

1,5

0 10 20 30 40 50 60 70 80 90

% Utilization

Rin

dep/R

WC

DO

Tmax/Tmin = 10Tmax/Tmin = 100Tmax/Tmin = 1000

Page 41: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 345FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Comparison with four processors and best-case>0

Analysis for: 4 processors 10 transactions 12 tasks per transaction best case > 0

1

1,5

2

2,5

3

3,5

4

4,5

5

0 10 20 30 40 50 60 70 80 90

% Utilization

Rin

dep/R

WC

DO

Tmax/Tmin = 10Tmax/Tmin = 100Tmax/Tmin = 1000

Page 42: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 346FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Maximum utilization with 20 tasks per transaction

Analysis for: 4 processors 5 transactions 20 tasks per transaction Tmax/Tmin=100

0

1

2

3

4

5

6

7

8

9

10

0 10 20 30 40 50 60 70 80 90

Maximum schedulable utilization

D/T

Independent tasksWCDO with best case=0WCDO with best case > 0

Page 43: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 347FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Room for improvement in offset-based analysisOffset-based analysis produces results that are much less pessimistic than other methods (i.e., holistic analysis)

But offset-based analysis still has room for improvement• a high priority task that is preceded by a low priority task may

not be able to execute before a medium priority task under analysis

Task-i2 Task-i3 Task-i4 Task-i5

Prio=High Prio=High Prio=Low Prio=High

Task-2Task under analysisPrio=medium

Task-i1

Prio=Low

Page 44: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 348FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Objectives of optimized offset-based analysisTo enhance the offset-based schedulability analysis by:• Eliminating from the analysis the effects of higher priority tasks

that cannot execute due to precedence constraints• Eliminating the effects of the tasks that are preceded by the task

under analysis

These enhancements reduce much of the pessimism in the analysis of distributed systems

Page 45: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 349FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Simulation results:response times

Analysis for: 1 processor 10 transactions 10 tasks per transaction Best case = 0

1

2

3

4

5

6

7

8

9

10

0 5 10 15 20 25 30 35 40 45 50% Utilization

Rin

dep/R

WCDOPS , = 10 WCDOPS , = 100WCDOPS , = 1000WCDO , = 10WCDO , = 100WCDO , = 1000

Page 46: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 350FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Simulation results:response times

Analysis for: 4 processors 10 transactions 12 tasks per transaction Best case > 0

1

1,5

2

2,5

3

3,5

0 5 10 15 20 25 30 35 40 45 50% Utilization

Rin

dep/R

WCDOPS , = 10 WCDOPS , = 100WCDOPS , = 1000WCDO , = 10WCDO , = 100WCDO , = 1000

Page 47: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 351FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Simulation results:utilization

Analysis for: 4 processors 5 transactions 20 tasks per transaction Tmax/Tmin = 100

0

10

20

30

40

0 1 2 3 4 5 6 7 8 9 10Relation D/T

Max

imum

util

izat

ion

Independent tasksWCDO with best case = 0WCDOPS with best case = 0WCDOPS with best case > 0

Page 48: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 352FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Simulation results:utilization

Analysis for: 4 processors 5 transactions 12 tasks per transaction Tmax/Tmin = 100

0

10

20

30

40

50

0 2 4 6 8 10Relation D/T

Max

imum

util

izat

ion

Independent tasksWCDO with best case = 0WCDOPS with best case = 0WCDOPS with best case > 0

Page 49: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 353FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Holistic analysis for EDF systemsDeveloped by Spuri• similar to the holistic analysis developed for fixed priorities at

the University of York

Each resource is analyzed separately (CPU’s and networks):• all activations after the first present “jitter”• jitter in one action is considered equal to the worst-case

response time of the previous actions• analysis in one resource affects response times in other

resources• the analysis is repeated, until a stable solution is achieved• the solution is pessimistic

Page 50: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 354FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Offset-based analysis for EDF (Palencia, 2003)

Dynamic offsets in distributed transactions can also be modeled with static offsets and jitter:• Equivalent offset:

• Equivalent jitter:

τi1 τi3 τi5τi4τi2

Distributed transaction Γi

Φ'ij Φij min, Rij 1–b= =

J'ij Jij Φij max, Φij min,–( )+ Rij 1– Rij 1–b–= =

Page 51: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 355FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Comparison with holistic analysis: 1 processor

Analysis for: 1 processor 10 transactions 5 tasks per transaction

1

1,5

2

2,5

3

3,5

4

4,5

5

0 10 20 30 40 50 60 70 80 90

% Utilization

Rin

dep/R

Offs

ets

Tmax/Tmin = 10Tmax/Tmin = 100Tmax/Tmin=1000

Page 52: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 356FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Comparison with four processors, and best-case=0

Analysis for: 4 processor 10 transactions 12 tasks per transaction best case = 0

1

2

3

4

0 10 20 30 40 50 60

% Utilization

Rin

dep/R

Offs

ets

Tmax/Tmin = 10Tmax/Tmin = 100Tmax/Tmin = 1000

Page 53: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 357FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Comparison with four processors and best-case>0

Analysis for: 4 processor 10 transactions 12 tasks per transaction best case > 0

1

2

3

4

5

0 10 20 30 40 50 60

% Utilization

Rin

dep/R

Offs

ets

Tmax/Tmin = 10Tmax/Tmin = 100Tmax/Tmin = 1000

Page 54: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 358FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Maximum utilization with 12 tasks per transaction

Analysis for: 4 processors 5 transactions 12 tasks per transaction Tmax/Tmin=100

0

1

2

3

4

5

6

7

8

9

10

0 10 20 30 40 50 60 70 80 90

Maximum schedulable utilization

D/T

Independent tasks

Offsets with best case=0

Offsets with best case >0

Page 55: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 359FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Summary of Analysis Techniques

Distributed model also applicable to:• signal & wait synchronization• activities that suspend themselves (i.e., delays, I/O, ...)

Kind of Analysis Deadlines Number of processors

Fixed Priorities EDF

Utilization test D=T 1Response Time Analysis Arbitrary 1Holistic Analysis Arbitrary ManyOffset-Based Analysis Arbitrary Many

Page 56: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 360FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Priority assignment techniquesNo known optimum priority assignment for distributed systems

Simulated Annealing• Standard optimization technique• Finds solutions by successively exchanging the priorities of a

pair of tasks, and reapplying the analysis to determine if results are worse or better

• The probability of the change surviving is a function of the results

• Does not guarantee finding the solution

Page 57: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 361FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Priority assignment techniques (cont’d)HOPA• Heuristic algorithm based on successively applying the analysis• Much faster than simulated annealing• Usually finds better solutions

None of them guarantees finding the solution

Page 58: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 362FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Fixed Priority Assignment Techniques in MAST

Monoprocessor: • If deadlines within periods, DM• Otherwise, Audsley’s algorithm: iteratively apply analysis,

successively ordering tasks by priority: O(n2) times the analysis

Technique Single-Processor

Multi-Processor

Monoprocessor

HOPA

Simulated Annealing

Page 59: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 363FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.7 Handling Task SuspensionIn many systems a task suspends itself waiting for a response from a remote resource.

Analysis of the suspending task: we can treat the suspension interval in two different (pessimistic) ways:• treat the suspension time as execution time,• or, treat each portion of the response as a different event.

Analysis of lower priority tasks: treat each portion of the response as a different event, but:• include the jitter effect of the second portion, or eliminate jitter.

Analysis with offsets can also be used for suspending tasks- less pessimism introduced

Page 60: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 364FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Example of a Suspending Task:

CPU-1 CPU-2

Serial Line

Task-1

Task-2 Task-4

Task-3

Task-5

Page 61: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 365FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Task parametersTasks 1, 2, 3, and 5 are periodic, and task 4 is a server task

The transmission times in the serial line: 25 and 34 ms., respectively for the request and the reply message.

The end-to-end deadline for task-2 is 150 ms

Task Ci Ti Di Pi1 4 20 20 High2 20+30 150 150 Low3 5 30 30 High4 15 - - Medium5 100 200 200 Low

Page 62: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 366FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Page 63: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 367FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Solution with Suspending TaskAnalysis in CPU-1:• treat suspension as execution time:

• treat each portion as a different task:

E2ak

T1----- C1 C21 M1 E4 M2 C22+ + + + + 165ms= =

E21ak

T1----- C1 C21+=

E22ak

T1----- C1 C22+=

E2 E21 M1 E4 M2 E22+ + + + 145ms= =

Page 64: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 368FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

The response time for task-1 is equal to C1=4 ms.

For the response time of task-2 we must take into account the suspension time, which is the transmission time of the request message (M1), plus the response time to task-4 (E4), and plus the transmission time for the reply message (M2). M1 and M2 are 25 and 34 ms. respectively, because the serial line is not used by any other task; otherwise a complete analysis should be performed for the communications line. E4 is 20 ms.; this value was obtained from the analysis of CPU-2, which is shown in the following slide.

The response time for task-2 can be determined using two different approaches:• Treating the suspension time as execution time: in this case the result is 165 ms.• Treating each portion of task-2 as a different task, and adding the two response times plus the

suspension time: in this case the result is 145 ms.

Both results may be pessimistic, i.e., they represent upper bounds to the worst-case execution time. Therefore, we can take the smallest (145 ms.) as the worst-case response time.

Page 65: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 369FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Solution (continued)Analysis in CPU-2:

The term E21+M1 incorporates the effect of jitter in the activation of task-4.

E3 C3 5ms= =

E4ak

T3----- C3 C4+ 20ms= =

E5ak

T3----- C3

ak E21 M1+ +T4

---------------------------------- C4 C5+ + 160ms= =

Page 66: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 370FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

The analysis of CPU-2 is conventional, except that task-4 is activated with jitter. This jitter has a schedulability penalty on lower priority tasks (i.e., on task-5). The amount of jitter that the activation of task-4 suffers is the variability of the first portion of task-2, and the request message. Supposing that both could sometimes be very short (near to zero) and in other occasions the worst case could happen (E21=28 ms. and M1=25 ms.), the total jitter could be 53 ms.

Notice that if we had not included the jitter effect in the equations, the result for task 5 would have been 140 ms., less that the actual worst-case that is 160 ms.

Page 67: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 371FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Analysis with offsetsIf we apply the analysis with offsets we get the following results:

Task Di Ri1 20 42 150 1453 30 54 - -5 200 140

Page 68: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 372FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Page 69: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 373FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

9.8 Multiprocessor SynchronizationExample: synchronization in a single processor

Processor P1τ1

τ2 τ3

r1 r2

0.5 ms. 0.5 ms.

1 ms. 1 ms.

P1=5

P2=3

Legend:τi:task-iri: resource-iPi:priority of task-iDi:Deadline of task-iCi:Execution time of

task-i

C1=4 ms.

C2=10 ms.P3=1C3=15 ms.

D1=8 ms.

Page 70: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 374FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

To illustrate multiprocessor synchronization, we will show an example of synchronization in a uniprocessor, and we will then extend it to a shared memory multiprocessor. Suppose the time-critical system with three periodic tasks that is shown in the figure above. One of the tasks, τ1, executes at high priority and has a deadline or worst-case latency requirement of 8 ms. The task takes 4 ms. to execute, including the time spent using two data structures that are shared with another two tasks. Two resources are used, r1 and r2, one for each shared data structure; their purpose is to allow a mutually exclusive access to the data structures from the different tasks. The figure shows the time spent by each task with the resource locked. The task periods are considered to be large.

We will assume that tasks τ1, τ2, and τ3 have been assigned priorities 5, 3, and 1 respectively, where a higher number corresponds to a higher priority. When the system is analyzed we find that unbounded priority inversion can appear when τ1 attempts to lock resource r2 while it is being owned by τ3. Under these circumstances τ1 has to wait for τ3 to complete its critical section but, because of its low priority level, τ3 may be preempted by τ2 and by any other task with priority between 1 and 5. One would have expected that the worst-case time that τ1 had to wait to acquire resource m2 was 1 ms., a function only of the duration of the critical section (which is usually short). However, unbounded priority inversion makes this time also depend on the duration of the execution of complete tasks. In our example, if τ2 takes10 ms. to execute, τ1 would have to wait for 11 ms. in the worst case due to this effect, and would certainly miss its critical deadline.

Page 71: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 375FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Timeline of Example (BIP)Worst-case latency, single processor, basic inheritance

τ1

τ2

τ3

Locks r2

Locks r1

Tries to lock r1 Tries to lock r2

6.5

0 4 8 10.2 12.4 14.5 time

Normal ExecutionResource LockedContext Switch

Page 72: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 376FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

Basic priority inheritance could be used to avoid unbounded priority inversion. Whenever τ1 is waiting to lock resource r2, its owner (τ3) inherits τ1’s priority level (5) and, therefore, it cannot be preempted by intermediate-priority tasks until it unlocks the resource. Consequently, the maximum time spent by task τ1 waiting for resources to become unlocked becomes only a function of the duration of critical sections. For this example this time is1 ms. for each resource, totaling 2 ms and allowing τ1 to meet its critical deadline. If we assume a non-negligible context switch time, in the worst case we would have to add two additional context switches for each of the resources that may be found locked. That makes in our example a total of one regular context switch needed to activate the task plus four additional context switches due to synchronization. If for example the context switch time is 0.1 ms., the total latency would be

where Ci is the worst case execution time of task-i, Cs is the context switch time, and is the maximum

time that τ1 will spend waiting for lower priority tasks to unlock resource ri. An execution sequence that leads to this worst-case latency is shown in the figure above.

Latency τ1( ) C1 CS Bri2CS+( )

r1 r2,∑+ + 4 0,1 1 0,2+( ) 1 0,2+( )+ + + 6,5 8≤= = =

Bri

Page 73: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 377FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Timeline of Example (IPC)Worst-case latency, single processor, immediate priority ceiling:

τ1

τ2

τ3

Locks r1

Locks r1 Locks r2

5.1

0 5 9 10.1 14.1 time

Locks r2

Page 74: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 378FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

On the other hand, if we use immediate priority ceiling protocol for this example, two advantages would immediately be achieved, if we assume no suspension inside critical sections. First, τ1 has to wait for at most one resource held locked by lower priority tasks. Second, the worst-case number of context switches due to synchronization becomes zero (only one remains for the activation of the task). This makes the total latency be:

An execution sequence that leads to this worst-case latency is shown in the figure above. It can also be seen that the immediate priority ceiling protocol preserves the blocked-at-most-once property by not letting τ2 preempt τ3 during its critical section

Latency τ1( ) C1 CS Max Br1Br2

,( )+ + 4 0,1 Max 1 1,( )+ + 5,1 8≤= = =

Page 75: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 379FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Multiprocessor ExampleSynchronization in a multiprocessor

Processor P1

τ1

τ2

r1

r2

0.5 ms.

0.5 ms.1 ms.

Processor P2

τ4

τ3 τ5

1 ms.

P3=1C3=15 ms.

P5= 4C5=12 ms.

P4=8C4=10 ms.

P2=3C2=10 ms.

P1=5C1=4 ms.D1=8 ms.

Page 76: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 380FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

Suppose that the system that appears in our example has growing demands for CPU utilization and a decision is made to move τ3 to another processor in the system. This processor had two other tasks assigned to it, τ4 and τ5, which have worst case execution times of 10 and 12 ms., respectively. We will assume a shared memory system and that no changes to the code of the different tasks needs to be made. We will also neglect, for simplicity, the effects of contention in the access to shared memory. The figure above shows the new structure of the system.

Page 77: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 381FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Remote Blocking in a MultiprocessorWorst-case latency, multiprocessor, basic inheritance

τ1

τ2

τ4

Locks r1

Tries to lock r1 Tries to lock r2

16.6

0 4 8.3 19.5

Locks r2

τ3

Locks r2

Unlocks r2

P1

P2

Remote Blocking

time

Page 78: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 382FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

Assuming that basic inheritance is being used we want to determine how much time does τ1 have to spend waiting for resources r1 or r2 to become unlocked. We can see that, because of priority inheritance, τ5 cannot influence this time, as its priority level is not high enough to preempt τ3 if inheritance has taken effect. However, τ4 is always able to preempt τ3, and the total time spent by τ1 waiting for r2 could be 11 ms. in the worst case. Task τ1 will miss its deadline because now its blocking time is again a function not only of the duration of critical sections but also of the execution of complete tasks. This effect is called remote blocking, and it has been shown that it can severely degrade the degree of CPU utilization in time-critical multiprocessor systems. The potential gain in computation power expected from the use of multiple processors is nullified because of this preemption effect across processors. The figure above shows an execution sequence that leads to this behavior.

Page 79: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 383FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Global Priority Ceiling ProtocolWorks the same as the priority ceiling protocol

The concept of priority ceiling is redefined:• Local resources (used from a single processor):

- Same as before (immediate priority ceiling)• Global resources (used from multiple processors):

- Above the priorities of any task in the system- Ordered according to the uniprocessor ceilings

This protocol avoids remote blocking as well as unbounded priority inversion

Page 80: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 384FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

Basic inheritance is clearly inadequate for synchronization in multiprocessors. Its properties are based on the existence of a single scheduler, so when multiple schedulers are present it fails to preserve the invariant of synchronization waiting times being only a function of the duration of critical sections. However, both unbounded priority inversion and remote blocking can be avoided by using the immediate priority ceiling protocol, and setting the priority ceilings of each resource to the appropriate levels. These levels are:

• Local resources, only used by tasks in the same processor: The local ceiling of a resource is defined as the highest of the priorities of all the tasks that may lock that resource.

• Global resources, used by tasks in at least two different processors. The ceiling of a global resource must be above the priorities of any of the tasks in the system. In this class of higher priority levels, the ceilings will be assigned such that resources with higher local ceiling (as defined above) are assigned a higher global ceiling.

The resultant protocol is called the global priority ceiling protocol.

Page 81: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 385FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Avoiding Remote BlockingWorst-case latency, multiprocessor, immediate priority ceiling

τ1

τ2

τ4

Locks r1

Locks r1 Tries to lock r2

0 4 8.1 19.3

Locks r2

τ3

Unlocks r2

P1

P2

6.2

time

Normal Blocking

Page 82: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 386FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

Suppose that we use global priority ceiling protocol for our multiprocessor example. Resource r1 is local and, therefore, it is assigned a ceiling of 5. Resource r2 is global and is assigned a priority ceiling higher than the priority of any other task in the system, for example priority 9. Immediate priority ceiling causes τ3’s critical section to be executed at priority level 9, thus avoiding any preemption effects from τ4 during the critical section. task τ4 now potentially experiences a new blocking effect due to the high priority execution of this critical section but this is still a function of the duration of critical sections. task τ1 is now blocked only for the duration of critical sections: its worst case waiting time is 1 ms. for each, r1 and r2, totaling a latency of 6 ms. and therefore meeting its deadline.

Page 83: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 387FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Summary of ExampleWorst-case latency results for τ1

1 Other tasks with priorities between 1 and 5.2 Other tasks in processor 2 with priorities above 3.3 Other tasks in processor 2 with priorities above 5.4 The actual worst-case number of context switches may slightly depend on the implementation or the timing requirements.

No Protocol Basic Inheritance

Global priority ceiling

Uniprocessor 15.0+other tasks1 6.0 5.0Uniprocessor & context switch4

15.5+other tasks1 6.5 5.1

Multiprocessor 28.0+other tasks2 16.0+other tasks3

6.0

Multiprocessor & context switch4

28.8+other tasks2 16.6+other tasks3

6.2

Page 84: 9.1 Introduction 9.2 Message passing systems 9.3 Real-time ...€¦ · 9. Distributed and multiprocessor systems 9.1 Introduction 9.2 Message passing systems 9.3 Real-time networks

GRUPO DE COMPUTADORES Y TIEMPO REAL REAL-TIME SYSTEMS 388FACULTAD DE CIENCIAS © José Carlos Palencia, Héctor Pérez Tijero 13/Feb/12

UNIVERSIDADDE CANTABRIA

Notes:

In summary:• In uniprocessors, the immediate priority ceiling protocol represents a better approach for the worst-

case response time than basic inheritance. It reduces the amount of time spent by higher priority tasks waiting for lower priority tasks to complete critical sections, and also reduces the worst-case amount of context switches.

• In multiprocessors, the global priority ceiling protocol represents a significantly better approach than basic inheritance for the worst-case response time. In fact, basic inheritance is unusable for most time-critical multiprocessor systems if high levels of CPU utilization are desired. It also makes the system be very sensitive to changes, because the unbounded nature of the latency causes a change made to one task to affect the latencies of tasks in other processors, even if the modified task does not synchronize with any other tasks. The global priority ceiling protocol solves the remote blocking problem and continues to minimize the number of worst-case context-switches due to synchronization.