Professional Documents
Culture Documents
Characterizing Real-Time
Systems
– inter-task constraints/parameters
• preemptivity
• context switch time
• time caused by blocking, Bi
• time caused by preemption
• precedence constraints
• data dependency
• temporal dependency
• criticality of tasks
Basic model
– bipartite graph
– BPN = ( P, T, A )
• P = { p1, p2, …, pn } places
• T = { t1, t2, …, tn } transitions
• A = { P x T } ∪ { T x P } directed arc
– Ai ⊆ P x T, Ao ⊆ T x P
transition
A job is being
directed arc
Job processing
is completed.
A job is on
the output list.
A job leaves Modeling of a simple
the computer system.
Spring 2001 Real-Time Systems (Shin) 8
Marked Petri Net
– tokens: A place pi has mi tokens.
– PN marking: M = { m1, m2, …, mn }
– model
• PN = ( P, T, A, M0 )
• M0 = { m01, m02, …, m0n } : net initial marking
– Rules
• A transition is enabled when all input places have
at least one token.
• Tokens ‘travel’ to the output places when the
enabled transition fires.
• The firing of a net produces new marking.
t1
P2 P3
t4 t2 t3
P4 P5
An example of t5
marked PN
t4 t3 t2
M4 = {0,0,0,1,1}
M1
t4 t5
M3 M0
t1 t4
P5
Before P2 P9
Crossing
up
t2 P6 P11
Within t6 t7
P3 t5
P7
P12 down
t3
Crossing
P10
Past
P4 P8
Computer
p1 t1, d1 p2
main power
weak OK
displays bt - wk
beep - rt
beep
light
t - hits - tm b
[in{enab}] on off
b - up
alarm-st chime-st
a[in{alarm}] c-enab
enab disab t-hits-hr d [in{chime}]
main
power
displays
update
t-min
c
min d
date weak
A state chart
b
c c
c
d
bt-wk for the digital
time
hour sec
c
watch
c a ok
date day chime a
c alarm
a
a
c
stopwatch zero c b
d[in{off}] b H up-alarm light
min
disp run hour
reg on
d c off
b c
[in{on}] d b t-min
lap off
H b b-up
on
beep-rt
t-tits-tm
2-min
beep [in{enab}]
[not in{stopwatch}]
alarm-st chime-st
c-enab d[in{chime}]
d[in{alarm}] t-hits-hr
enab disab c-beep quit c-disab
beep-st
d[in{alarm}] d[in{chime}]
start_loop L1:
exp exp
S ==> exit_if_false
==> JRF L2
stmt stmt
end_loop JRA L1
L2:
where JRF means “jump_relative if false,”
and JRA means “jump_relative always.”
T(exp) : T(expcode)
T(stmt) : T(stmtcode)
T(while,N) : N · T(JRF, fail) + T(JRF, succ) + N ·
T(JRA)
Language analyzer
Parser
Procedure Loop
times bounds
Time schema
Code prediction
Architecture analyzer
Spring 2001 Real-Time Systems (Shin) 28
An example using the timing tool
struct {
int key;
int value;
} data[15];
binary_search(x)
{
int favalue, mid, up, low ;
[low bound, upper bound]
low = 0 ;
[ 16, 16 ]
up = 14 ;
[ 20, 20 ]
fvalue = -1 / * all data are positive */;
[ 20, 20 ]
Spring 2001 Real-Time Systems (Shin) 29
while (low <= up)
*** WHILE statement ***
Input LOOP-BOUNDS [1, 4]
{
mid = (low + up) >> 1;
[ 52, 52 ]
if ( data[mid].key == x ) { /* found */
up = low - 1;
[ 40, 40 ]
fvalue = data[mid].value;
[ 72, 72 ]
} [ 112, 112 ]
else /* not found */
if (data[mid].key > x ) up = mid - 1; [ 40, 40 ]
else low = mid + 1; [ 40, 40 ]
[ 128, 134 ]
[ 206, 222 ]
}
[ 258, 274 ]
[ 352, 1340 ]
t i
Task 3 tTS i 1
n
Task 2
Task 1
t 1 t 2 t 3 Time
Interrupt
Handler
Current
Running
Task
t IL Time
Task 2
Task 1
t1 t2 t3 t4 t5
Time
Task 1 t SS
requests Task 1
semaphore relinquishes
semaphore
Task 2 has a higher priority. Task 2 Task 2
requests obtains
semaphore semaphore
Task 1
low priority
t1 t2 t3 t4 t5 t6
tA tB
Task 1
gets a resource Task 1
releases
the resource
Task 3 Task 3
requests gets the
the resource resource
Acknowledgement
Real-time
application
programs
Design Execution
environment environment
– feasible schedule
• definition: a valid schedule by which
every task completes by its deadline
• a set of tasks is schedulable according to
a scheduling algorithm if the scheduler
always produces a feasible schedule
• a hard real-time scheduling algorithm is
optimal if the algorithm always produces
a feasible schedule for a given set of
tasks