los fichios

This commit is contained in:
Raphaël LACROIX 2023-03-31 14:13:28 +02:00
parent e6dbce040f
commit f570469914
31 changed files with 867 additions and 0 deletions

BIN
SCpart2.pdf Normal file

Binary file not shown.

140
TP1/TP1.md Normal file
View file

@ -0,0 +1,140 @@
# TP1: problème du choix distant
Familiarisez vous avec loutil UPPAAL.
Le point fort dUppaal cest le temps; ici on ne lutilise que pour simuler/vérifier des _produits dautomates asynchrone_ (vous verrez le temps lan prochain).
Ce TP est facile; il faut avoir commencé le TP2 avant la fin de la première séance.
## Étudiez les différents onglets de léditeur graphiques
* `editor` qui permet de modifier les _déclarations_; les _templates_ de processus; et la _déclaration du système_
* `simulator` affiche le _système instancié_ et permet dexplorer les états du système
* `verifier` le model-checker intégré à UPPAAL
## Il y a trois types de fichiers (extensions)
* `.xta` format textuel pour définir des _process_ ; déclarer de nouveaux types et constantes; et déclarer le _system_. Vous pouvez écrire directement dans ce format.
* `.ugi` format de déclaration des propriétés graphiques (couleur et emplacement des états, … ). Utilisé en interne par loutil.
* `.q` format _query_, pour déclarer de nouvelles propriétés
* il y a aussi possibilité dutiliser un langage `XML`
## Synchronisation en UPPAAL
Les transitions dun _template_/_process_ UPPAAL peuvent avoir quatre types de propriétés
<figure>
<img src="docs/1586956621847.png" alt="Edit edge in UPPAAL" />
<figcaption>Fig. 1: edit edge in UPPAAL</figcaption>
</figure>
* `select` choix “non-déterministe” dune valeur
* `guard` (condition) sur les données
* `sync` synchronisation sur un canal
* `update` mis à jour des données
Une transition sans `sync` est dite interne. Elle peut se déclencher indépendamment des autres instances de process.
Il y a deux _polarités_ sur les canaux `!` (émettre) et `?` recevoir. On peut émettre sur un canal `a` (noté `a!`) ou recevoir (noté `a?`).
> __Convention:__ on dit que le message transite de `a!` vers `a?`
&nbsp;
> __Convention:__ on exécute toujours lupdate de lémetteur avant celui du récepteur (utile seulement si on a des données)
## Espace détat dun système
On peut explorer les états du système en construisant un graphe qui énumère toutes les transitions/synchronisations possibles depuis un état; en partant de __létat initial__.
Cest ce quon appelle la __sémantique__ du système.
Le _model-checking_, cest utilisé des formules de logique temporelle pour “poser des questions” sur le graphe, par exemple pour découvrir la présence de _deadlock_ (états sans transitions sortantes); savoir si le système est _vivant_ et/ou ré-initialisable; …
<figure>
<img src="docs/state_space.png" alt="State space for the first example" />
<figcaption>Fig. 2: espace d'état pour l'exemple de la question 1</figcaption>
</figure>
## Rappel sur les formules de logique temporelle en UPPAAL
Il existe des formules qui parlent de “létat courant” du système: conjonction, notée `and`; disjonction, notée `or`; et négation, notée `not`, de _propriétés atomiques_.
* linstance `gauche` est dans létat `a` sécrit `gauche.a`
* la valeur de la variable `cpt` de linstance `FifoRI` est inférieure à 2 sécrit `FifoRI.cpt <=2`
Il y a des modalités
* deux _modifiers_ de contexte: `A` (All, ∀) et `E` (Exists, ∃)
* deux modalités temporelles: `[]` (partout, tout le temps) et `<>` (éventuellement)
* donnent 4 possibilités (`A[]`, `E[]`, `A<>`, `E<>`) + une formule spéciale (_leadsto_) `.. > ..`
Il est impossible dimbriquer (dutiliser) une formule à lintérieur dune autre: `E<> gauche.a` est correct, mais pas `(E<> gauche.a) > gauche.b`
Les formules parlent et quantifient des __chemin maximaux__ dans le __graphe/espace détat__ du système.
| | `[]` | `<>` |
|:----:|:--------------------------------:|:----------------:|
| `A` | __always__ | __inevitably__ |
| `E` | __potentially__<br />__always__ | __reachable__ |
> __Exemple de formules classiques:__
>
> * `A[] not deadlock` (invariant) toujours létat nest pas un deadlock
## Données et expressions en UPPAAL
On peut définir des variables, en plus des canaux, en utilisant une syntaxe “à la C” avec différents types de données possible
* `int[0,3] x;` déclare une variable `x` qui peut prendre comme valeur 0, 1, 2 ou 3
* `int y;` domaine par défaut
* `int tab[n];` tableau de `n` valeurs, de `tab[0]` à `tab[n-1]`
On peut aussi définir des constantes `const bool KO = false;`
Ces valeurs peuvent être utilisées pour instancier des paramètres, et donc pouvoir définir deux instances dun même _template_ qui ont des comportements différents.
<figure>
<img src="docs/1586962032896.png" />
<figcaption>Fig. 3: exemple d'utilisation de paramètres et déclarations locales dans un template</figcaption>
</figure>
```uppaal
gauche = Agent(0);
droit = Agent(1);
system gauche, droit;
```
## Format textuel
On peut également écrire un modèle UPPAAL directement dans le format XTA (textuel)
```uppaal
int[0,1] vp;
chan s, a, b ;
process Agent(int kind) {
int lkind := kind;
state
idle,
choice,
before_a,
before_b;
init idle;
trans
before_b -> idle { guard lkind==1; sync b!; },
before_a -> idle { guard lkind==1; sync a?; assign lkind := 1 - lkind; },
idle -> choice { guard lkind==1; sync s?; },
idle -> choice { select p : int[0,1]; guard lkind==0; sync s!; assign vp := p; },
choice -> before_a { guard (vp == 1); },
choice -> before_b { guard vp == 0; },
before_a -> idle { guard lkind==0; sync a!; assign lkind := 1 - lkind; },
before_b -> idle { guard lkind==0; sync b?; };
}
gauche = Agent(0);
droit = Agent(1);
system gauche, droit;
```

BIN
TP1/docs/1586872833702.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
TP1/docs/1586956621847.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
TP1/docs/1586962032896.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1 @@
<mxfile host="Electron" modified="2020-04-15T14:44:04.949Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.9.9 Chrome/80.0.3987.163 Electron/8.2.1 Safari/537.36" etag="QTVhlJCNsItAytQ2R7D_" version="12.9.9" type="device"><diagram id="fHMpaOG2JjDkD6-WRv7L" name="Page-1">3VpLc5swEP41PjoDEi8fEydpD+1MO55Om146MghDg5Eryw/66yuMBMgEjJ+Q+mJ29d79vl0hMYDj+fYDRYvgM/FwNACatx3AxwEAuuZY/C/VJJnG0YRiRkMvU2mFYhL+xbKl0K5CDy+FLlMxQiIWLlSlS+IYu0zRIUrJRq3mk8hTFAs0wxXFxEVRVfs99FggtLo1Kgo+4nA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TLBC8uFt8mZR4ovvCCT/8A</diagram></mxfile>

BIN
TP1/docs/state_space.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

3
TP1/docs/state_space.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

36
TP1/question1/rdv.ugi Normal file
View file

@ -0,0 +1,36 @@
process Left graphinfo {
templateName (5,5);
paramList (0,15);
location idle (256,112);
locationName idle (-10,-30);
location choice (190,80);
locationName choice (-10,-30);
location after_a (256,216);
locationName after_a (-10,-30);
location after_b (256,0);
locationName after_b (-10,-30);
location reinit (340,80);
locationName reinit (-10,-30);
sync idle choice 1 (1,-24);
sync choice after_a 1 (-23,-4);
sync choice after_b 1 (-23,-16);
sync reinit idle 1 (-18,-24);
}
process Right graphinfo {
templateName (5,5);
paramList (0,15);
location idle (258,83);
locationName idle (-10,-30);
location choice (167,84);
locationName choice (-10,-30);
location after_a (259,188);
locationName after_a (14,-4);
location after_b (264,-17);
locationName after_b (19,-13);
location reinit (340,80);
locationName reinit (-10,-30);
sync idle choice 1 (-9,-22);
sync choice after_a 1 (-23,2);
sync choice after_b 1 (-25,-14);
sync reinit idle 1 (-3,-21);
}

29
TP1/question1/rdv.xta Normal file
View file

@ -0,0 +1,29 @@
/* Probleme du choix distant */
chan s, a, b, f;
process Left{
state idle, choice, after_a, after_b, reinit;
urgent idle, choice, after_a, after_b, reinit;
init idle;
trans idle -> choice{sync s!; },
choice -> after_a{sync a!; },
choice -> after_b{sync b?; },
after_a -> reinit{},
after_b -> reinit{},
reinit -> idle{sync f?; };
}
process Right{
state idle, choice, after_a, after_b, reinit;
urgent idle, choice, after_a, after_b, reinit;
init idle;
trans idle -> choice{sync s?; },
choice -> after_a{sync a?; },
choice -> after_b{sync b!; },
after_a -> reinit{},
after_b -> reinit{},
reinit -> idle{sync f!; };
}
gauche := Left();
droit := Right();
system gauche, droit;

42
TP1/question1/specifs.q Normal file
View file

@ -0,0 +1,42 @@
//This file was generated from UPPAAL 3.4.5, Mar 2004
/*
Absence de blocage
*/
A[] not deadlock
/*
Pb de synchro
*/
E<> gauche.after_a and droit.after_b
/*
Pb de synchro
*/
E<> gauche.after_b and droit.after_a
/*
Possibilite d'avoir des communications sur a (gauche -> droite)
*/
E<> gauche.after_a
/*
Possibilite d'avoir des communications sur b (droite -> gauche)
*/
E<> gauche.after_b
/*
Possibilite d'avoir infiniment des communications sur a (gauche -> droite)
*/
E[] not gauche.after_b
/*
Possibilite d'avoir infiniment des communications sur b (droite -> gauche)
*/
E[] not gauche.after_a

30
TP1/question2/nondet.xta Normal file
View file

@ -0,0 +1,30 @@
/* Probleme du choix distant: Choix interne */
chan s, a, b, f;
process Left{
state idle, choice, before_a, before_b, after_a, after_b;
urgent idle, choice, before_a, before_b, after_a, after_b;
init idle;
trans idle -> choice{sync s!; },
choice -> before_a{},
choice -> before_b{},
before_a -> after_a{sync a!; },
before_b -> after_b{sync b?; },
after_b -> idle{sync f?; },
after_a -> idle{sync f?; };
}
process Right{
state idle, choice, before_a, before_b, after_a, after_b;
urgent idle, choice, before_a, before_b, after_a, after_b;
init idle;
trans idle -> choice{sync s?; },
choice -> before_a{},
choice -> before_b{},
before_a -> after_a{sync a?; },
before_b -> after_b{sync b!; },
after_a -> idle{sync f!; },
after_b -> idle{sync f!; };
}
gauche := Left();
droit := Right();system gauche, droit;

42
TP1/question2/specifs.q Normal file
View file

@ -0,0 +1,42 @@
//This file was generated from UPPAAL 3.4.5, Mar 2004
/*
Absence de blocage
*/
A[] not deadlock
/*
Pb de synchro
*/
E<> gauche.after_a and droit.after_b
/*
Pb de synchro
*/
E<> gauche.after_b and droit.after_a
/*
Possibilite d'avoir des communications sur a (gauche -> droite)
*/
E<> gauche.after_a
/*
Possibilite d'avoir des communications sur b (droite -> gauche)
*/
E<> gauche.after_b
/*
Possibilite d'avoir infiniment des communications sur a (gauche -> droite)
*/
E[] not gauche.after_b
/*
Possibilite d'avoir infiniment des communications sur b (droite -> gauche)
*/
E[] not gauche.after_a

29
TP1/question3/nondet.xta Normal file
View file

@ -0,0 +1,29 @@
/* Probleme du choix distant: Choix interne */
chan s, a, b ;
process Left{
state idle, choice, before_a, before_b;
urgent idle, choice, before_a, before_b;
init idle;
trans idle -> choice{sync s!; },
choice -> before_a{},
choice -> before_b{},
before_a -> idle{sync a!; },
before_b -> idle{sync b?; };
}
process Right{
state idle, choice, before_a, before_b;
urgent idle, choice, before_a, before_b;
init idle;
trans idle -> choice{sync s?; },
choice -> before_a{},
choice -> before_b{},
before_a -> idle{sync a?; },
before_b -> idle{sync b!; };
}
gauche := Left();
droit := Right();
system gauche, droit;

42
TP1/question3/specifs.q Normal file
View file

@ -0,0 +1,42 @@
//This file was generated from UPPAAL 3.4.5, Mar 2004
/*
Absence de blocage
*/
A[] not deadlock
/*
Pb de synchro
*/
E<> gauche.after_a and droit.after_b
/*
Pb de synchro
*/
E<> gauche.after_b and droit.after_a
/*
Possibilite d'avoir des communications sur a (gauche -> droite)
*/
E<> gauche.after_a
/*
Possibilite d'avoir des communications sur b (droite -> gauche)
*/
E<> gauche.after_b
/*
Possibilite d'avoir infiniment des communications sur a (gauche -> droite)
*/
E[] not gauche.after_b
/*
Possibilite d'avoir infiniment des communications sur b (droite -> gauche)
*/
E[] not gauche.after_a

BIN
TP1/tp1.pdf Normal file

Binary file not shown.

95
TP2/TP2.md Normal file
View file

@ -0,0 +1,95 @@
# TP2: problème du choix distant en asynchrone
Dans la séance précédente vous avez vu comment créer de nouveaux _templates_ (de processus); déclarer des variables; utiliser les _gardes_ et les _updates_ (mises à jour) dans les transitions pour simuler le passage de valeurs dans les communications.
Dans cette nouvelle séance, vous allez étudier plus profondément la notion _dinstanciation_ de système. Lobjectif est de modéliser le comportement dun système communicants au-dessus dun réseau asynchrone, à capacité bornée, dans lequel les messages ne peuvent pas se dépasser (FIFO).
## Le process Fifo
le process `fifo` modélise le comportement dun canal de communication FIFO à capacité (`cap`) finie.
```uppaal
process fifo(const int cap, chan &get, chan &put, int &vget, int &vput){
int cpt := 0;
int buf[cap];
int ixP := 0;
int ixG := 0;
state service, erreur;
init service;
trans
service -> service{
guard cpt > 0;
sync get!;
assign vget:= buf[ixG],
cpt:= cpt - 1, ixG:= (ixG == (cap - 1))?0:(ixG + 1);
},
service -> service{
guard cpt < cap;
sync put?;
assign buf[ixP]:= vput, cpt:= cpt + 1,
ixP:= (ixP == (cap - 1))?0:(ixP + 1);
};
}
```
Une instance de `fifo`contient un buffer (`buf`) de capacité `cap` , un compteur du nombre de message contenu dans `buf` (la variable `cpt`) et deux canaux en paramètres qui définissent les _services_ du composant: `put` pour ajouter un message et `get`pour récupérer le message le plus ancien. Chacun de ces services est associé à une variable, `vput` et `vget`, qui sert à communiquer une valeur lors dune synchronisation.
<figure>
<img src="docs/fifo.png" alt="Le composant FIFO" />
<figcaption>Fig. 1: Le composant FIFO</figcaption>
</figure>
La fifo se comporte comme un _buffer circulaire_; on écrit à la position `ixP` et on lit à la position `ixG`. On nefface jamais les messages écrit mais on peut réécrire dessus.
<figure>
<img src="docs/uppaal_buffer_circulaire.jpg" alt="Buffer circulaire" />
<figcaption>Fig. 2: Buffer circulaire</figcaption>
</figure>
## Le système “choix asynchrone”
Le système global est constitué de deux instances de `fifo`et deux instances du composant `site`. Un site peut émettre (sur le canal `out` en utilisant la variable `vout` ) ou recevoir (sur `in`).
```uppaal
chan LRGET, LRPUT;
int LRVG, LRVP;
chan RLGET, RLPUT;
int RLVG, RLVP;
process site(chan &in, chan &out, int &vin, int &vout){ ... }
process fifo(const int cap, chan &get, chan &put, int &vget, int &vput){ ... }
FifoLR := fifo(4,LRGET,LRPUT,LRVG,LRVP);
FifoRL := fifo(4,RLGET,RLPUT,RLVG,RLVP);
gauche := site(RLGET,LRPUT,RLVG,LRVP);
droit := site(LRGET,RLPUT,LRVG,RLVP);
system gauche, FifoLR, FifoRL, droit;
```
En suivant les déclarations, on voit que le canal (paramètre) `out` de linstance `gauche` de `site` est `LRPUT`, qui est aussi le canal `put` de linstance `FifoLR` de `fifo`. Donc le site gauche émet ses messages dans FifoLR, et ces messages arriveront éventuellement sur un `in?` du site droit.
On peut illustrer ces relations à laide dun schéma comme celui en Fig. 3.
<figure>
<img src="docs/uppaal_instantiation.jpg" />
<figcaption>Fig. 3: instantiation du système choixasync</figcaption>
</figure>

62
TP2/choixasync.xta Normal file
View file

@ -0,0 +1,62 @@
/* Probleme du choix distant en asynchrone avec controle de flux */
chan LRGET, LRPUT;
int LRVG, LRVP;
chan RLGET, RLPUT;
int RLVG, RLVP;
process site(chan &in, chan &out, int &vin, int &vout){
int mesg;
state idle, apres_envoi, apres_recoit;
urgent idle, apres_envoi, apres_recoit;
init idle;
trans
idle -> apres_envoi{sync out!; assign vout := 5;},
idle -> apres_recoit{sync in?; assign mesg := vin;},
apres_envoi -> idle{},
apres_recoit -> idle{};
}
process fifo(const int cap, chan &get, chan &put, int &vget, int &vput){
int cpt := 0;
int buf[cap];
int ixP := 0;
int ixG := 0;
state service, erreur;
urgent service, erreur;
init service;
trans
service -> service{
guard cpt > 0;
sync get!;
assign vget:= buf[ixG],
cpt:= cpt - 1, ixG:= (ixG == (cap - 1))?0:(ixG + 1);
},
service -> service{
guard cpt < cap;
sync put?;
assign buf[ixP]:= vput, cpt:= cpt + 1,
ixP:= (ixP == (cap - 1))?0:(ixP + 1);
};
}
FifoLR := fifo(4,LRGET,LRPUT,LRVG,LRVP);
FifoRL := fifo(4,RLGET,RLPUT,RLVG,RLVP);
gauche := site(RLGET,LRPUT,RLVG,LRVP);
droit := site(LRGET,RLPUT,LRVG,RLVP);
system gauche, FifoLR, FifoRL, droit;

89
TP2/cointossing.xta Normal file
View file

@ -0,0 +1,89 @@
chan LRGET, LRPUT;
int LRVG, LRVP;
chan RLGET, RLPUT;
int RLVG, RLVP;
chan cvg, cvd; // canaux synchrones entre site et voteur
process fifo(const int flux, const int cap, chan & get, chan &put, int &vget, int &vput){
int cpt := 0;
int buf[cap];
int ixP := 0;
int ixG := 0;
int cdf := flux;
state service, erreur;
urgent service, erreur;
init service;
trans
service -> service{
guard cpt > 0;
sync get!;
assign vget:= buf[ixG],
cpt:= cpt - 1, ixG:= (ixG == (cap - 1))?0:(ixG + 1);
},
service -> service{
guard cpt < cap;
sync put?;
assign buf[ixP]:= vput, cpt:= cpt + 1,
ixP:= (ixP == (cap - 1))?0:(ixP + 1);
},
service -> erreur{
guard cpt == cap and cdf == 0; sync put?; };
}
process player(chan &choice, const int gain1, const int gain2, chan &in, chan &out, int &vin, int &vout){
/* A Completer */
state repos,idle ;
urgent repos,idle ;
init repos;
trans
repos -> idle{sync choice?;};
}
process site(chan &choice, chan &in, chan &out, int &vin, int &vout){
/* A Completer */
int mesg;
state idle, wait, envoi, apres_envoi, recoit, apres_recoit;
urgent idle, wait, envoi, apres_envoi, recoit, apres_recoit;
init idle;
trans
idle -> wait{sync choice!;},
wait -> envoi{sync choice?;},
wait -> recoit{sync choice?;},
envoi -> apres_envoi{sync out!; assign vout := 5;},
recoit -> apres_recoit{sync in?; assign mesg := vin;},
apres_envoi -> idle{},
apres_recoit -> idle{};
}
FifoLR := fifo(0,4,LRGET,LRPUT,LRVG,LRVP);
FifoRL := fifo(0,4,RLGET,RLPUT,RLVG,RLVP);
gauche := site(cvg,RLGET,LRPUT,RLVG,LRVP);
droit := site(cvd,LRGET,RLPUT,LRVG,RLVP);
Voteurgauche := player(cvg, 1,1,RLGET,LRPUT,RLVG,LRVP);
Voteurdroit := player(cvd, 0,2,LRGET,RLPUT,LRVG,RLVP);
system Voteurgauche, gauche, FifoLR, FifoRL, droit, Voteurdroit;

BIN
TP2/docs/fifo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

42
TP2/spec1.q Normal file
View file

@ -0,0 +1,42 @@
//This file was generated from UPPAAL 3.4.5, Mar 2004
/*
Absence de blocage
*/
A[] not deadlock
/*
Pb de synchro
*/
E<> gauche.apres_envoi and droit.apres_envoi
/*
Pb de synchro
*/
E<> gauche.apres_recoit and droit.apres_recoit
/*
Possibilite d'avoir des communications sur a (gauche -> droite)
*/
E<> gauche.apres_envoi
/*
Possibilite d'avoir des communications sur b (droite -> gauche)
*/
E<> gauche.apres_recoit
/*
Possibilite d'avoir infiniment des communications sur a (gauche -> droite)
*/
E[] not gauche.apres_recoit
/*
Possibilite d'avoir infiniment des communications sur b (droite -> gauche)
*/
E[] not gauche.apres_envoi

BIN
TP2/tp2.pdf Normal file

Binary file not shown.

45
TP3/TP3.md Normal file
View file

@ -0,0 +1,45 @@
# TP3: protocole de communication
On sintéresse ici à la conception de système de télécommunications, du type protocoles téléphoniques, qui assurent la connexion et la déconnexion de session entre deux utilisateurs.
Ici on suppose que votre réseau na que deux utilisateurs
<p><a href="https://commons.wikimedia.org/wiki/File:Tr%C3%A5dtelefon-illustration.png#/media/Fichier:Trådtelefon-illustration.png"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0a/Tr%C3%A5dtelefon-illustration.png" alt="Trådtelefon-illustration.png"></a><br>This is from Project Runeberg book called <a rel="nofollow" class="external text" href="http://runeberg.org/huru/0081.html">The key to science</a> In swedish., Domaine public, <a href="https://commons.wikimedia.org/w/index.php?curid=472708">Lien</a></p>
On réutilise le “réseau FIFO” de la séance précédente. Au lieu de faire communiquer deux sites, on met en relation un processus `initiateur` (une instance du template `initia`) avec un processus `repondeur` (une instance du template `resp`).
```uppaal
FifoIR := fifo(4,FIRGET,FIRPUT,PFIR,GFIR);
FifoRI := fifo(4,FRIGET,FRIPUT,PFRI,GFRI);
repondeur := resp(FIRGET,FRIPUT,PFRI,GFIR);
initiateur := initia(FRIGET,FIRPUT,PFIR,GFRI);
system initiateur, FifoIR, FifoRI, repondeur;
```
On considère deux type de message possibles, cest-à-dire deux valeurs possibles pour les messages écrit dans le buffer des FIFO (alors que, typiquement, on ne transmettait que la valeur 5 dans le TP 2). La valeur `cr` correspond à un _call request_; `dr` (pour drrriiiiiing ?) correspond à un _drop request_ , qui signale la fin ou le refus dune session.
```uppaal
const int cr = 1;
const int dr = 0;
```
Au cours des questions du TP, le comportement de chaque service est décrit à laide de schémas, ou _automates de services_. Je donne ci-dessous une idée de la correspondance entre un automate et “léquivalent” en UPPAAL (où on a simplifié la notion des communications).
<figure>
<img src="docs/service_automata.png" />
<figcaption>Fig. 1: correspondance entre "automates de services" et UPPAAL</figcaption>
</figure>
> __Remarque:__ un processus qui implante un automate de service, par exemple `initiateur`, doit envoyer un message (par exemple `sync put!; assign vput :=cr;`) lorsque le service attend de recevoir un “call request” (la transition est `init(sup)? appel`). Ne soyez donc pas surpris si vous pensez que les polarités sont inversées dans ces schémas.

58
TP3/cdcv0.ugi Normal file
View file

@ -0,0 +1,58 @@
process resp graphinfo {
templateName (5,5);
paramList (0,15);
location idle (40,80);
locationName idle (-10,-30);
location waitme (190,80);
locationName waitme (-10,-30);
location open (312,80);
locationName open (-10,-30);
location rns (304,-8);
locationName rns (-10,-30);
trans idle waitme 1 (-3,-72);
sync idle waitme 1 (-19,-88);
assign idle waitme 1 (-35,-72);
guard waitme open 1 (-43,0);
sync waitme open 1 (-43,15);
assign waitme open 1 (-43,30);
guard waitme idle 1 (-43,0);
sync waitme idle 1 (-43,16);
assign waitme idle 1 (-43,32);
guard waitme rns 1 (-23,-20);
}
process initia graphinfo {
templateName (5,5);
paramList (0,15);
location idle (40,80);
locationName idle (-10,-30);
location waitother (190,80);
locationName waitother (-10,-30);
location open (190,230);
locationName open (-10,-30);
location rec_waitohter (40,230);
locationName rec_waitohter (24,10);
sync idle waitother 1 (-60,-15);
assign idle waitother 1 (-60,0);
sync waitother rec_waitohter 1 (5,-35);
assign waitother rec_waitohter 1 (5,-20);
guard rec_waitohter open 1 (-43,-22);
guard rec_waitohter idle 1 (-60,-30);
}
process fifo graphinfo {
templateName (5,5);
paramList (0,15);
location service (40,80);
locationName service (-10,-30);
location error (190,80);
locationName error (-10,-30);
trans service service 1 (-24,48),(24,48);
guard service service 1 (-44,-22);
sync service service 1 (-44,-7);
assign service service 1 (88,-64);
trans service service 2 (-30,-30),(30,-30);
guard service service 2 (-60,-30);
sync service service 2 (-60,-15);
assign service service 2 (-60,0);
guard service error 1 (-60,-30);
sync service error 1 (-60,-15);
}

49
TP3/cdcv0.xta Normal file
View file

@ -0,0 +1,49 @@
int GFIR, PFIR;
int GFRI, PFRI;
chan FIRGET, FIRPUT;
chan FRIGET, FRIPUT;
const int cr = 1;
const int dr = 0;
process resp(chan &get, chan &put, int &vput, int &vget){
int[0,1] mesg;
state idle, waitme, open, rns;
urgent idle, waitme, open, rns;
init idle;
trans idle -> waitme{sync get?; assign mesg := vget; },
waitme -> open{guard mesg == cr; sync put!; assign vput :=cr; },
waitme -> idle{guard mesg == cr; sync put!; assign vput :=dr; },
waitme -> rns{guard mesg != cr; };
}
process initia(chan &get, chan &put, int &vput, int &vget){
int[0,1] mesg;
state idle, waitother, open, rec_waitohter, rns;
urgent idle, waitother, open, rec_waitohter,rns;
init idle;
trans idle -> waitother{sync put!; assign vput :=cr; },
waitother -> rec_waitohter{sync get?; assign mesg := vget; },
rec_waitohter -> open{guard mesg == cr; },
rec_waitohter -> idle{guard mesg == dr; };
}
process fifo(const int cap, chan &get, chan &put, int &vput, int &vget){
int cpt := 0;
int buf[cap];
int ixP := 0;
int ixG := 0;
state service, error;
urgent service, error;
init service;
trans service -> service{guard cpt > 0; sync get!; assign vget:= buf[ixG], cpt:= cpt - 1,
ixG:= (ixG == (cap - 1))?0:(ixG + 1); },
service -> service{guard cpt < cap; sync put?; assign buf[ixP]:= vput,
cpt:= cpt + 1, ixP:= (ixP == (cap - 1))?0:(ixP + 1); },
service -> error{guard cpt == cap; sync put?; };
}
FifoIR := fifo(4,FIRGET,FIRPUT,PFIR,GFIR);
FifoRI := fifo(4,FRIGET,FRIPUT,PFRI,GFRI);
repondeur := resp(FIRGET,FRIPUT,PFRI,GFIR);
initiateur := initia(FRIGET,FIRPUT,PFIR,GFRI);system initiateur, FifoIR, FifoRI, repondeur;

View file

@ -0,0 +1 @@
<mxfile host="Electron" modified="2020-04-16T14:24:21.905Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.9.13 Chrome/80.0.3987.163 Electron/8.2.1 Safari/537.36" etag="CKuKDij8VdbJ8J80Cmcd" version="12.9.13" type="device"><diagram id="gvMQsScEsYjPKJWbFy-M" name="Page-1">7VtLc+I4EP4tc6Bq9zApv7GPCQm7WzXZShW1NTtHxRZGM8byGBFgf/3KWPJDcrAcMJhJcsFqPWz141N3qzMyJ8vtHylIFo84gNHI0ILtyLwfGYauuQ79ySi7nOJqjBCmKMhJWkmYof8gn8moaxTAFaPlJIJxRFBSJ/o4jqFPajSQpnhTHzbHUVAjJCCEEmHmg0imfkUBWTCq7nhlx58QhQv2atcY5x1LwAeznawWIMCbCsl8GJmTFGOSPy23ExhlzKvzZfpKb/FhKYyJyoS/Hn9+Re7T7un7318sa+PP/1lPPutsGy8gWrMds68lO86CMMXrRH4b+4AXmBK4bZIFeOYrlNulegLxEpJ0R8fxWZxDO85c1t6UDLcdRltUeF0oCWBCDou1Sz7QB8aKLmxp5wpdheogbdxtFojAWQL8rGdDzYDSFmRJX3iv00ewSnLFnKMtpC+9k1l5WDQig2VGFrYl8c1tYJvbG9d0mUsBtSbWxClZ4BDHIHooqXdUueIg48u9RlvlmC8YJ4yD3yEhOwYNYE1wnb9wi8i/2fQbm7W+scWy5/tttbHjjZjutzIpa36r9pXT9i0+b0VS/KMAAotS5iiKJjjC6X6/ZmBDN7CKkZUe13g2Hae7+Fd4nfrwwECGNwSkITy4YD4uk8hBZUphBAh6qeNfk67sp96mKdhVBiQYxWRVWfkpI5TGXmgf01lTAC1huHVoNH3IX1+qbLGPt2vx+Lpsn/NV4NSlscBV4GL/2NBqr/M5dHy/yV6DsfesaT3YK/di2ux1fGp7PQ7bLyK/ZmzX34Tt+rHYPnd92Kwrz65t2X3oindV2G4Ljhz3zxTBX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 KiB

32
TP3/spec0.q Normal file
View file

@ -0,0 +1,32 @@
//This file was generated from UPPAAL 3.4.5, Mar 2004
/*
Absence de blocage
*/
A[] not deadlock
/*
Inevitabilite d' ouvrir une connexion
*/
A<> initiateur.open and repondeur.open
/*
Possibilite d' ouvrir une connexion
*/
E<> initiateur.open and repondeur.open
/*
Taille de la fifo (R->I) <= 1
*/
A[] FifoRI.cpt <=1
/*
Possibilite de reception non specifiee (rns) pour le repondeur
*/
E<> repondeur.rns
/*
Possibilite de reception non specifiee (rns) pour l'initiateur
*/
E<> initiateur.rns

BIN
TP3/tp3.pdf Normal file

Binary file not shown.