UniTO/anno2/YearI/SecondSem/VPC/labs/uppaal/ProdCons.xml
Francesco Mecca 5e286062f8 MCAD 2019
2018-11-22 13:09:11 +01:00

173 lines
4.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
<nta>
<declaration>/*
* Four vikings are about to cross a damaged bridge in the middle of the
* night. The bridge can only carry two of the vikings at the time and to
* find the way over the bridge the vikings need to bring a torch. The
* vikings need 5, 10, 20 and 25 minutes (one-way) respectively to cross
* the bridge.
* Does a schedule exist which gets all four vikings over the bridge
* within 60 minutes?
*/
</declaration>
<template>
<name x="32" y="16">Prod</name>
<parameter> chan &amp;lput</parameter>
<declaration>clock px;</declaration>
<location id="id0" x="289" y="76">
<name x="279" y="42">ready</name>
</location>
<location id="id1" x="178" y="195">
<name x="162" y="211">done</name>
</location>
<location id="id2" x="64" y="80">
<name x="56" y="48">work</name>
</location>
<init ref="id2"/>
<transition>
<source ref="id1"/>
<target ref="id2"/>
<label kind="assignment" x="82" y="137">px:=0</label>
</transition>
<transition>
<source ref="id0"/>
<target ref="id1"/>
<label kind="synchronisation" x="255" y="127">lput!</label>
<nail x="280" y="178"/>
</transition>
<transition>
<source ref="id2"/>
<target ref="id0"/>
<label kind="guard" x="127" y="51">px&gt;=2</label>
</transition>
</template>
<template>
<name>Cons</name>
<parameter>chan &amp;lget</parameter>
<declaration>clock cx;</declaration>
<location id="id3" x="138" y="141">
<name x="122" y="157">done</name>
</location>
<location id="id4" x="24" y="26">
<name x="16" y="-6">work</name>
</location>
<location id="id5" x="249" y="22">
<name x="239" y="-12">ready</name>
</location>
<init ref="id4"/>
<transition>
<source ref="id3"/>
<target ref="id4"/>
<label kind="assignment" x="42" y="83">cx:= 0</label>
</transition>
<transition>
<source ref="id5"/>
<target ref="id3"/>
<label kind="synchronisation" x="215" y="73">lget!</label>
<nail x="240" y="124"/>
</transition>
<transition>
<source ref="id4"/>
<target ref="id5"/>
<label kind="guard" x="87" y="-3">cx&gt;=2</label>
</transition>
</template>
<template>
<name x="32" y="-16">Buf</name>
<parameter>chan &amp;lput, chan &amp;lget</parameter>
<location id="id6" x="68" y="8">
<name x="58" y="-26">Half</name>
</location>
<location id="id7" x="-76" y="0">
<name x="-92" y="-32">Empty</name>
</location>
<location id="id8" x="212" y="0">
<name x="204" y="-32">Full</name>
</location>
<init ref="id7"/>
<transition>
<source ref="id7"/>
<target ref="id6"/>
<label kind="synchronisation" x="1" y="8">lput?</label>
<nail x="-17" y="42"/>
</transition>
<transition>
<source ref="id6"/>
<target ref="id7"/>
<label kind="synchronisation" x="-34" y="-59">lget?</label>
<nail x="0" y="-42"/>
</transition>
<transition>
<source ref="id6"/>
<target ref="id8"/>
<label kind="synchronisation" x="85" y="34">lput?</label>
<nail x="136" y="51"/>
</transition>
<transition>
<source ref="id8"/>
<target ref="id6"/>
<label kind="synchronisation" x="144" y="-68">lget?</label>
<nail x="118" y="-50"/>
</transition>
</template>
<system>const int fastest = 5;
chan put, get; // Take and release torch
clock time; // Global time
Client = Prod(put);
Service = Cons(get);
Buffer = Buf(put,get);
system Client, Service, Buffer;</system>
<queries>
<query>
<formula>A[] not deadlock
</formula>
<comment>The system is deadlock free.
</comment>
</query>
<query>
<formula>E&lt;&gt; Viking1.safe
</formula>
<comment>Viking 1 can cross the bridge.
</comment>
</query>
<query>
<formula>E&lt;&gt; Viking2.safe
</formula>
<comment>
</comment>
</query>
<query>
<formula>E&lt;&gt; Viking3.safe
</formula>
<comment>
</comment>
</query>
<query>
<formula>A[] not (Viking4.safe and time&lt;slowest)
</formula>
<comment>
</comment>
</query>
<query>
<formula>E&lt;&gt; Viking4.safe imply time&gt;=slowest
</formula>
<comment>
</comment>
</query>
<query>
<formula>E&lt;&gt; Viking1.safe and Viking2.safe and Viking3.safe and Viking4.safe
</formula>
<comment>Scheduling problem reformulated as reachability formula. Use
'Diagnostic Trace:Fastest' option to find fastest solution.
</comment>
</query>
</queries>
</nta>