SPB Git

Repository Public MIT Research preview

MA02-F07-course-et-version.tex 2.8 KB 39 lines latex

1% MA02-F07 — Race condition (mise à jour perdue) et correction par versionnement, sur deux agents et un compteur.2% Idée : chacun lit, « réfléchit » (un await : l'autre passe), puis écrit. Sans contrôle, la seconde écriture écrase3% la première. Avec un numéro de version, la seconde écriture est REFUSÉE : l'agent relit et recommence.4% Schéma de deux agents ; la bande du bas donne les nombres de l'expérience à cinq agents (MA02-donnees.tex).5\input{MA02-donnees.tex}%6\begin{tikzpicture}[x=1mm, y=1mm]7  \path (0,0) rectangle (142,56);8  \newcommand{\MBpanneau}[2]{% origine x, titre9    \node[atlas heading, anchor=west] at (#1,53.8) {#2};10    \foreach \x/\nom in {8/agent A, 33/magasin, 58/agent B}{11      \node[atlas block, minimum width=15mm, minimum height=5mm, inner ysep=1.4pt, font=\AtlasSizeTiny\bfseries] at (#1+\x,48.4) {\nom};12      \draw[maNeutre, line width=.6pt, dash pattern=on 1.6pt off 1.6pt] (#1+\x,45.8) -- (#1+\x,9.6);}}13  \newcommand{\MBmsg}[6][atlas arrow]{% [style] origine, x départ, x arrivée, y, texte14    \draw[#1] (#2+#3,#5) -- (#2+#4,#5);15    \pgfmathsetmacro{\xm}{#2+(#3+#4)/2}16    \node[fill=maFond, inner xsep=1pt, inner ysep=.2pt, font=\AtlasSizeTiny, text=maTexte, anchor=south] at (\xm,#5+.3) {#6};}17  % --- Sans contrôle18  \MBpanneau{0}{Sans contrôle}19  \MBmsg{0}{33}{8}{41.6}{lit 0}20  \MBmsg{0}{33}{58}{36.4}{lit 0}21  \MBmsg{0}{8}{33}{31.2}{écrit 0 + 1}22  \MBmsg[atlas arrow hazard]{0}{58}{33}{26}{écrit 0 + 1}23  \node[atlas note, anchor=west, text=maRisque, align=left] at (36,20.4) {écrase l'écriture de A};24  \node[draw=maRisque, line width=1.4pt, fill=maPanneau, rounded corners=1.6pt, inner xsep=4pt, inner ysep=2.4pt, font=\AtlasSizeTiny\bfseries, text=maTexte] at (33,12.6) {compteur = 1, attendu 2};25  % --- Avec version26  \draw[maNeutre, line width=.5pt] (71,9) -- (71,55);27  \MBpanneau{75}{Avec un numéro de version}28  \MBmsg{75}{33}{8}{42.2}{lit 0, v0}29  \MBmsg{75}{33}{58}{37.6}{lit 0, v0}30  \MBmsg[atlas arrow valid]{75}{8}{33}{33}{écrit 1 si v0 : accepté, v1}31  \MBmsg[atlas arrow hazard]{75}{58}{33}{28.4}{écrit 1 si v0 : refusé}32  \MBmsg{75}{33}{58}{23.8}{relit 1, v1}33  \MBmsg[atlas arrow valid]{75}{58}{33}{19.2}{écrit 2 si v1 : accepté, v2}34  \node[draw=maValide, line width=1.4pt, fill=maPanneau, rounded corners=1.6pt, inner xsep=4pt, inner ysep=2.4pt, font=\AtlasSizeTiny\bfseries, text=maTexte] at (108,12.6) {compteur = 2, un conflit, un essai de plus};35  % --- Nombres de l'expérience36  \node[atlas tag=maDecision, anchor=south west] at (0,0) {SIMULATION};37  \node[atlas note, anchor=south west, text=maTexte] at (22,.2) {\MBEtatAgents\ agents × \MBEtatIncrements\ ajouts, attendu \MBEtatAttendu\ : sans contrôle \textbf{\MBEtatNaifValeur} · verrou \textbf{\MBEtatVerrouValeur} · version \textbf{\MBEtatOptValeur} (\MBEtatOptConflits\ conflits)};38\end{tikzpicture}39
Files main
Menu

Theme