\documentclass{uebungsblatt}
\author{Marek Kubica, kubica@in.tum.de}
\fach{Grundlagen Betriebssysteme}
\blatt{4}
\gruppe{22}

\usepackage{tikz}
\usetikzlibrary{arrows,decorations,backgrounds,petri,positioning,fit,calc}

\begin{document}

\aufgabe

\teilaufgabe

\begin{tikzpicture}
  [node distance=3.0cm,
   re/.style={<-,shorten <=1pt,>=stealth’,semithick},
   post/.style={->,shorten >=1pt,>=stealth’,semithick},
   place/.style={circle,draw=blue!50,fill=blue!20,thick, minimum size=8mm},
   transition/.style={rectangle,draw=black!50,fill=black!20,thick,minimum height=10mm,minimum width=4mm}]

  \node[place] (outside) [label=above:Außerhalb,
                          tokens=1] {};
  \node[transition] (entering) [label=above:betritt Bank,
                                right of=outside] {};
  \node[place] (counseling) [label=above:Beratung,
                             right of=entering] {};
  \node[transition] (leaving) [label=above:verlässt Bank,
                               right of=counseling] {};
  \draw [->,thick] (outside) to (entering);
  \draw [->,thick] (entering) to (counseling);
  \draw [->,thick] (counseling) to (leaving);
  \draw [->,thick] (leaving.south) -- ++(0,-.5) -| (outside.south);

\end{tikzpicture}

\teilaufgabe

\begin{tikzpicture}
  [node distance=3.0cm,
   re/.style={<-,shorten <=1pt,>=stealth’,semithick},
   post/.style={->,shorten >=1pt,>=stealth’,semithick},
   place/.style={circle,draw=blue!50,fill=blue!20,thick, minimum size=8mm},
   transition/.style={rectangle,draw=black!50,fill=black!20,thick,minimum height=10mm,minimum width=4mm}]

  \node[place] (outside) [label=above:Außerhalb,
                          tokens=1] {};
  \node[transition] (entering) [label=above:betritt Bank,
                                right of=outside] {};
  \node[place] (inside) [label=above:Innerhalb,
                         right of=entering] {};
  \node[transition] (tocounsel1) [label=above:Berater 1,
                                  above right of=inside] {};
  \node[transition] (tocounsel2) [label=above:Berater 2,
                                  below right of=inside] {};
  \node[place] (counseling1) [label=above:Beratung 1,
                             right of=tocounsel1] {};
  \node[place] (counseling2) [label=above:Beratung 2,
                             right of=tocounsel2] {};
  \node[transition] (leaving) [label=above:verlässt Bank,
                               below right of=counseling1] {};
  \draw [->,thick] (outside) to (entering);
  \draw [->,thick] (entering) to (inside);
  \draw [->,thick] (inside) to (tocounsel1);
  \draw [->,thick] (inside) to (tocounsel2);
  \draw [->,thick] (tocounsel1) to (counseling1);
  \draw [->,thick] (tocounsel2) to (counseling2);
  \draw [->,thick] (counseling1) to (leaving);
  \draw [->,thick] (counseling2) to (leaving);
  \draw [->,thick] (leaving.south) -- ++(0,-2.5) -| (outside.south);
\end{tikzpicture}

\aufgabe

\teilaufgabe

\begin{tikzpicture}[>=latex,join=bevel,]
  \pgfsetlinewidth{1bp}
%%
\pgfsetcolor{black}
  % Edge: d -> e
  \draw [->] (52bp,90bp) .. controls (50bp,77bp) and (46bp,60bp)  .. (41bp,36bp);
  \draw (57bp,63bp) node {t1};
  % Edge: d -> f
  \draw [->] (70bp,91bp) .. controls (81bp,78bp) and (96bp,58bp)  .. (115bp,35bp);
  \draw (105bp,63bp) node {t2};
  % Edge: a -> c
  \draw [->] (67bp,271bp) .. controls (74bp,258bp) and (83bp,239bp)  .. (94bp,215bp);
  \draw (91bp,243bp) node {t1};
  % Edge: a -> b
  \draw [->] (53bp,270bp) .. controls (49bp,257bp) and (44bp,240bp)  .. (36bp,216bp);
  \draw (56bp,243bp) node {t2};
  % Edge: c -> d
  \draw [->] (94bp,181bp) .. controls (87bp,168bp) and (78bp,149bp)  .. (65bp,125bp);
  \draw (89bp,153bp) node {t4};
  % Edge: f -> c
  \draw [->] (126bp,36bp) .. controls (121bp,68bp) and (113bp,133bp)  .. (106bp,180bp);
  \draw (124bp,108bp) node {t3};
  % Node: a
\begin{scope}
  \pgfsetstrokecolor{black}
  \draw (58bp,288bp) ellipse (27bp and 18bp);
  \draw (58bp,288bp) node {s1};
\end{scope}
  % Node: c
\begin{scope}
  \pgfsetstrokecolor{black}
  \draw (103bp,198bp) ellipse (27bp and 18bp);
  \draw (103bp,198bp) node {s3};
\end{scope}
  % Node: b
\begin{scope}
  \pgfsetstrokecolor{black}
  \draw (31bp,198bp) ellipse (27bp and 18bp);
  \draw (31bp,198bp) node {s2};
\end{scope}
  % Node: e
\begin{scope}
  \pgfsetstrokecolor{black}
  \draw (37bp,18bp) ellipse (37bp and 18bp);
  \draw (37bp,18bp) node {s3,s4};
\end{scope}
  % Node: d
\begin{scope}
  \pgfsetstrokecolor{black}
  \draw (56bp,108bp) ellipse (37bp and 18bp);
  \draw (56bp,108bp) node {s1,s4};
\end{scope}
  % Node: f
\begin{scope}
  \pgfsetstrokecolor{black}
  \draw (129bp,18bp) ellipse (37bp and 18bp);
  \draw (129bp,18bp) node {s2,s4};
\end{scope}
%
\end{tikzpicture}

\teilaufgabe

Nein, es besteht keine Nebenläufigkeit, da $t_3$ nicht schaltbar ist,
also blokiert und damit die nicht-sequenzielle Ausführung verhindert.

\teilaufgabe

Ja, wenn man von der Ausgangslage die Transition $t_2$ schaltet, dann
verklemmt das System, da sich der Token in $s_2$ befindet, aber $t_3$
nicht schaltbar ist.

\teilaufgabe

Ja, denn wenn man nur boolsche Belegungen zulässt entsteht ein Deadlock
wenn man über $t_1$, $t_4$ und danach nochmal $t_1$ geht, denn dann ist
in $s_4$ bereits ein Token, also kann die Transition $t_4$ nicht mehr
geschaltet werden. Dadurch dass man ganzzahlige Belegungen erlaubt,
verschwindet diese Deadlock-Möglichkeit, da man nun in $s_4$ beliebig
viele Tokens anhäufen kann und somit $t_4$ immer schaltbar bleibt.

\teilaufgabe

Wenn immer $t_1$ und danach $t_4$ ausgelöst werden, werden die Transitionen
$t_2$ und $t_3$ ausgehungegert, da zwar in $s_4$ eine Menge Tokens
angesammelt werden, aber $t_3$ nie geschaltet werden kann, da in
$s_2$ nie Tokens vorhanden sind.

\end{document}

