Formelsamling för TDDC47 Realtids- och processprogrammering Formelsamling f&ouml;r TDDC47 Realtids- och processprogrammering
2010
Notation for Algorithms
Assignment is denoted by “=”. Comparison (equality) is denoted by “==”.
Semaphore
wait(S)
if S &gt; 0 then S = S-1 else
suspend the process calling wait(S)
signal(S)
if some process P has been suspended by
an earlier wait(S), then wake up P
Banker’s safety algorithm
1. Let Work and Finish be vectors of length m and n,
respectively. Initialize:
Work = Available
Finish[i] = false for i = 1,2, …, n.
2. Find an i such that both:
(a) Finish[i] == false
(b) Needi  Work
If no such i exists, go to step 4.
3. Work = Work + Allocationi
Finish[i] = true
go to step 2.
4. If Finish[i] == true for all i, then the system is in a
safe state.
Formelsamling f&ouml;r TDDC47 Realtids- och processprogrammering
1. Let Work and Finish be vectors of length m and n,
respectively. Initialize:
(a) Work = Available
(b) For i = 1,2, …, n,
if Allocationi  0 then
Finish[i] = false
else
Finish[i] = true
2. Find an index i such that both:
(a) Finish[i] == false
(b) Requesti  Work
If no such i exists, go to step 4.
3. Work = Work + Allocationi
Finish[i] = true
go to step 2.
5. If Finish[i] == false for some i, 1  i  n then
the system is in deadlock state.
Moreover, if Finish[i] == false, then Pi is deadlocked
2010
Formelsamling f&ouml;r TDDC47 Realtids- och processprogrammering
Notation for Processes
C
B
D
n
T
R
J
= Worst-case execution time
= Worst-case blocking time
= Number of processes
= Period
= Worst-case response time
= Release jitter
Schedulability test for Rate Monotonic:
 Ci 
   n(21 / n  1)

i 1  Ti 
n
 Ci 
  1
i 1  i 
n
  T
Response time analysis
wi  Ci  Bi 
Ri  wi  J i
 wi  J j 

C j

T
Pjhp ( Pi ) 
j

hp(Pi) is the set of processes with a higher priority than process Pi.
Worst case execution time analysis
Atomic operations (assignments, expressions, statements):
WCET(atom) = φ(atom) /* time to execute ”atom” */
Sequence:
WCET(S1; S2) = WCET(S1) + WCET(S2)
Selection:
WCET (if E then S1 else S2) =
WCET(E) + max(WCET(S1), WCET(S2))
Iteration:
WCET (while E do S) =
WCET(E) + Nmax*(WCET(S)+WCET(E))
2010
Formelsamling f&ouml;r TDDC47 Realtids- och processprogrammering
Timing Analysis of CSMA/CR
B = blocking time
C = transmission time of entire frame
T = period
bit = transmission time of one bit
w = response time for the first bit of a frame to be sent
R = total response time
J = Jitter
t = Longest busy interval
lp(m) = set of frames with lower priority than m.
hp(m) = set of frames with higher priority than m.
hep(m) = set of frames with higher or equal priority than m.
n = number of bytes in message (data field)
Rm  max ( Rm (q))
q  0..Qm 1
Rm (q)  J m  wm (q)  q  Tm  Cm
wm (q)  Bm  q  C m 
(with
 wm (q )  J j   bit 

 C j

T
jhp ( m ) 

j
wm (q )  Bm  Cm q )
0
t  Jm 
Qm   m

 Tm 
t  J j 
tm  Bm    m
 Cj
Tj 
jhep (m ) 
(with

 34  8n  1 
C m   8n  47  
  bit
4



Bm  max (C j )
jlp ( m )
0
t m  Cm )
2010