P = (a -> b -> P). Q = (c -> b -> Q). ||S1 = (P || Q). S2 = (a -> c -> b -> S2 | c -> a -> b -> S2).Generate traces for ||S1 and S2. Can one generate a different trace from the other? Are the processes the same? Why?
X||Y = x -> (X' || Y') , if x=y (and are in C) (P1)
X||Y = (x -> (X' || y->Y')
|y -> (x->X' || Y')) , if x,y are not in C (P2)
X||Y = x -> (X' || y->Y') , if y is in C and x is not (P3)
X||Y = y -> (x->X' || Y') , if x is in C and y is not (P3')
P1 = (x1 -> P1).
||P1_2 = (a1:P1 || a2:P1).
P2 = (x1 -> x2 -> P2).
||P2_2 = (a1:P2 || a2:P2).
||P2_3 = (a1:P2 || a2:P2 || a3:P2).
How many states do each of these processes have? If we defined in
the above fashion ||Px_y, i.e. y
independent process with x states combined in parallel, how
many states would this process have?
Note: if you do Build -> compose for these processes in the LTSA tool, you can check your answer on the Output pane!
SERVERv2 = (accept.request -> service -> accept.reply -> SERVERv2).
CLIENTv2 = (call.request -> call.reply -> continue -> CLIENTv2).
||CLIENT_SERVERv2 = (CLIENTv2 || SERVERv2) / {call/accept}.
Hint: prefix the CLIENT prcesses
and then do the renaming.
COUNTDOWN (N=3) = (start -> COUNTDOWN[N]),
COUNTDOWN[i:0..N] = ( when (i>0) tick -> COUNTDOWN[i-1]
| when (i==0) beep -> STOP
| stop -> STOP).
The CountDownTerm.java
program is meant to be an implementation of this.
The main program thread performs the stop
action; it only performs this if the counter thread, which performs the
tick and beep actions, is not running:
if (c.counter.isAlive()) c.stop(); // sets c.counter to null then prints "stop"Why does this not prevent the erroneous behaviour ... tick tick stop beep? That is, the program can produce the output:
... tick:(count=1) stop beepWhat (if any) erroneous behaviour does the guard prevent?
Hint: in the above situation, the main thread performs the actions:
P = (a -> b -> P). Q = (c -> b -> Q). ||S1 = (P || Q). S2 = (a -> c -> b -> S2 | c -> a -> b -> S2). ||S2 = S2Hint: load each of the two processes in separate tools. Build -> Compile and Build -> Compose each. Now Build -> Minimize ||S2.
You will notice now that the main thread stops much earlier, but the java CountDownTerm process does not terminate until the counter thread does.
Hint: model the last iteration of the while loop of run() only in the process COUNTER with alphabet {ctr.read[0..1], print.tick, threadExit} . The process MAIN has the alphabet {isAlive[0..1], ctr.write[0], print.stop}. Model the value of initially non-null counter in the process CTR with alphabet {ctr.read[0..1], ctr.write[0]}. Finally, model the thread state in a process THREADSTATE with alphabet {isAlive[0..1], threadExit}.
Kudos to those who shed some light on this issue.