Professional Documents
Culture Documents
Curs 4 - PetriNets - StateMachine - PN PDF
Curs 4 - PetriNets - StateMachine - PN PDF
Design of R- T Applications
Execution
Specifications Control Synthesis Tests Integration
Environment
SubmachineState1
State1 T1 State2
T5 T4
State3 T2 State4
T3 State6
State5
= T5(T1&T2&T3)T4
=T5(T1T2T3 +T1T3T2 +T2T3T1 +T2T1T3 +T3T2T1 +T3T1T2)T4.
Semaphore
acquire(P3) must be atomic
+permits: int
release(P3) must be atomic
+acquire()
+release()
Mutual exclusion P3
What parts of the program are mutual excluded?
Tiberiu Leia: Real-Time Systems Transformation PN-SM-PN 5
SubmachineState1
T1.acquire(P3) T3/release(P3) S6
S1 S4
T0 T5
T2.acquire(P3) T4/release(P3) S7
S2 S5
[semList=!empty]/grant
rel(sem)/
Semaphore P3 SM Legend:
Releasing acq(sem): acquire the semaphore sem
rel(sem): release the semaphore sem
[semList==empty] entry/rem(solicitor,semList) semList: semaphore sem list
add: add a new solicitor in the list
rem: remove a solicitor form the list
SubmachineState1
P5 T4
T1
P1 P3
T0 T3
T2 T5
P2 P4 P6
Double synchronization 1
Prove the equivalence of the two models!
Try the semaphore implementation. (?!?)
P5 T4
T1
P1 P3
T0 T3
T2 T5
P2 P4 P6
Implementation solutions:
- Barrier
- join()
SubmachineState1
/wait() receive_notify()/
X Wait V
/notify()
Y Z
If T2 and notify() are executed before wait(), the end markings are m(X)=1, m(Z)=1.
=T0[2]T1[4]T2[3]= T0(2)T1(6)T2(9)
Prove the equivalence!
T0[2] relative time
T0(2) absolute time
tick[x!=0]/x--
Clock
wait(x)/t=x
Wait
start
UpperThread
T2.wait(3)
P2
T1.wait(4)/reset(P1)
T0.wait(2)/set(p1)
P1
T3.wait(3)/reset(P1)
LowerThread
T4.wait(4) T5.wait(1)
P3 P4
tick[x!=0]/x--
Clock
wait(x)/t=x
start
Wait
/wait(3)
=T0[0]((T1[2]T3[4])&(T2[3]T4[5]))T5[0] T6[0]=
T0(0)((T1(2)T3(6)) & (T2(3)T4(8))T5(8+) T6(8++)
T8(8++) T0 and T5 were supposed to be executed immediately.
entry/EntryAction1
do/DoAction1
exit/ExitAction1
Tiberiu Leia: Real-Time Systems Transformation PN-SM-PN 27
Asynchronuous approach - Deadlock with variable timming
1=T0[0](T1(1)T3(1+)T5(3)T7(6+)&T2(6+)T4(6++)T6(8)T8(10+))T9[0]T11[0]
NO Deadlock
2=T0[0]((T1(1)T3(1+)T5(5?))&(T2(4)T4(4+) ))T9[0]T11[0] Deadlock
Conclusion: Sometimes the program is deadlocked and sometimes is not.
1=T0[0+](T1(3)T3(7;13) &T2(2)T4(7;13))T5(7+;13+)T6[3]T7[0]
T0(10++;16++) ....
Conclusion: Sometimes YES and sometimes NO Answer: NO for real-time systems.
IF periodConstraint=17 YES
Homework: Get an implementation such that the period is always 18 t.u.
How can this be programmed using Java language?
Tiberiu Leia: Real-Time Systems Transformation PN-SM-PN 29
Output arc
of transition
M(P5)
If two or more transitions are executed simultaneously the place P5 is loaded with the
number of tokens equal with the number of threads. The transition execution
semantics is changed!
1 2
U
The processor loading is given by formula: 10 1 15 2
Example: Thread1 has the priority 3 and Thread2 has the priority 5. The time slice
durations fulfills:
1 2
3 5 1
How can the processor loading be calculated in this case? Is it different from the
previous case?
entry/EntryAction1
do/DoAction1
exit/ExitAction1
+acquire()
+release()
How are the threads periods from the next PN? Can they be calculated?
[4;5]
[4;5]
Thread3