B - People - Kansas State University

About the Use of Correlations in
Component Based Frameworks
Georg Jung
[email protected]
Department of Computing and Information Sciences
Kansas State University
Why Using Correlators?
Consider the following situation:

A
a

C
ab
b
B

Component C is
receiving from two
components A and B
A and B send at
different rates
C needs both inputs
to become active
Why Using Correlators!
If we add
Consider
correlations
to
the infrastructure
the following situation:
A
a
a +ab
b
b
B
C
We can:
 Reduce network
traffic
 Simplify computation
inside the component
 Clarify the design
 Define the
components in a
more general way
Hello World!
Scenario:
Example scenario from introduction slides:
A
• Three Components A, B,
and C
C
• Component C receives
• A and B send at different
rates
B
Hello World!
φC correlation HelloWorld
(φA a, φB b) Head
a + b
Filter
{
Transformer
case true:
push new φC { x := a.data,
y := b.data }
}
The Two-Phase Model
Conceptually, the correlator divides into two
Reacting
to
a
Information
about:
distinct phases:
detected pattern
 which events arrived
Stream
of incoming
1.
The
Filter
what
dataevents
is present
2. e
The
Transformer
e
e1 e2 e2
1
3
Filter
Detection
of
Transformer
event patterns
Generates new output events
Filter
e
e
out
out
And
performsabout:
internal actions
Information
 which events arrived
 what data is present
Transformer
Back to “Hello World!”
φC correlation HelloWorld
(φA a, φB b)
a + In
b this simple example
{
the transformer does
a type conversion!
case true:
push new φC { x := a.data,
y := b.data }
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Race Condition
Scenario:
Components A and B carry out a task and
deliver the results to C.
Component C expects the results to come
in first from A, then from B.
The resulting race condition between
A and C can be caught with a
correlator.
Race Condition
Solution:
φdata correlation CatchRacing (φdata a, φdata b)
a + b
{
case true:
push a;
push b;
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Most Recent / Earliest
Scenario:
A component C receives from A and B.
a + b
when both events arrive, C wants the most
recent (earliest) of both forwarded.
We change the filter expression to:
la:(a ; b) | lb:(b ; a)
Most Recent / Earliest
φData correlation First
(φData a; φData b)
la:(a; b) | lb:(b; a)
{
case la: push a;
case lb: push b;
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Double Match
Consider the following filter expression:
(a + b) | (a + c)
And the following streams:
a b a a c c … matches: a + b
a c a b b a … matches: a + c
c b b c a a … matches: a + b
and
a + c
Double Match
l1:(a + b) | l2:(a + c)
Adding Labels to the expression
(a + b) | (a + c)
Double Match
l1:(a + b) | l2:(a + c)
Transformer 1: Send a general notification
{
}
case true: push new φnote {};
Double Match
l1:(a + b) | l2:(a + c)
Transformer 2: Send two outputs
{
case l1: push b;
case l2: push c;
}
Double Match
l1:(a + b) | l2:(a + c)
Transformer 3: Send one output, with
priority on b if present.
{
case l1: push b;
case l2 & !l1: push c;
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Interleaving Event
We consider three subexpressions x1, x2, x3.
x2 shall not interleave between x1 and x3.
x1 ; (l2:(x2 ; x3) | l3:x3)
φ correlation Interleaving (...)
x1 ; (l2:(x2 ; x3) | l3:x3)
{
case l2: push some error event;
case l3 & !l2: push some success event;
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Redundant-Sensor-Array
Consider an array of redundant components
A1, A2, …, An.
and a single receiving component B,
interested in the accumulation of all events
a1, a2, …, an.
The filter expression is then
a1 + a2 + … + an
An
A
A2 3
A1
+
B
Redundant-Sensor-Array
a1 + a2 + … + an
In a component system some components
can be temporarily unavailable!
If one component does not send anymore
the whole pattern is never satisfied!
An
A
A2 3
A1
+
B
Redundant-Sensor-Array
Notify correlation SensorArray
(Notify a1, …, Notify an,
Control c1, …, Control cn)
l1:a1 + … + ln:an || m1:c1 || … || mn:cn
{ case l1 & … & ln: push new Notify {}
case m1: toggle l1
…
case mn: toggle ln C
}
An
A
A2 3
A1
Sensor
Array
B
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Mode-Awareness
Scenario:
This scenario generalizes the previous.
Instead of single devices to switch on or
off, we have a several modes to chose
from.
The same mechanism is used
to switch between modes
as previously to switch the
different devices on and off.
Mode Awareness
n filter expressions, labeled with n labels:
m1:e1 || … || mn:en
n labeled control events:
l1:c1 || … || ln:cn
Mode Awareness
φout correlation Modal3
(φc c1, φ c c2, φ c c3, arguments for ei…)
m1: e1 || m2: e2 || m3: e3 ||
l1: c1 || l2: c2 || l3: c3
{
abort (m2, m3);
clauses for e1, e2, e3…
case l1: revive (m1); abort (m2, m3);
case l2: revive (m2); abort (m1, m3);
case l3: revive (m3); abort (m1, m2);
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to handle a double match
 How to catch interleaving events
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems
Periodic Checks of Aperiodic Events
Scenario:
We introduce a periodic supervisor
component into an aperiodic system.
Whenever a clock-tick occurs, a sample is
collected and sent to the supervisor.
Periodic Checks of Aperiodic Events
φsample correlation PeriodicChck
(φtimer t, φa a, φb b, φc c)
t ; (l1:(a + b + c) | l2:t)
{
case l1:
push new φsample{d1 := a.data,
d2 := b.data,
d3 := c.data }
case l2:
push some error event (missed sample);
}
Examples
This presentation will include:
 How to prevent a race condition
 How to chose the most recent/earliest in a
sequence
 How to These
handle are
a double
match
our examples.
 How to
catch
interleaving
events
Feel
free
to add your
own…
 How to deal with redundant-device-components
 How to introduce mode-dependent behavior
 How to bridge the gap between periodic and
aperiodic systems