
\input menv
\input stuki

\newdimen\conspace\conspace=2pt
\newdimen\spspace\spspace=4pt
\def\con#1{\vskip\conspace\item{}#1\vskip\conspace}
\def\conp#1#2{\vskip\conspace\item{#1}#2\vskip\conspace}

\newcount\spsw\spsw=0
\def\var(#1:#2){\ifodd\spsw{$\times $}\else{\global\spsw=1}\fi
            {\baselineskip 9pt\vtop{\hbox{#1}\hbox{$#2$}}}}
\def\sp#1{\vskip\spspace\global\spsw=0\item{}$#1=$}
\def\edef{\mathrel{\mathop=^{{\fiverm def}}}}

\font\kiscimf=cmbx10
\font\kiemf=cmssqi8
\newcount\tetelc\tetelc=0
\newcount\altetelc\altetelc=0
\newcount\alaltetelc\alaltetelc=0
\def\tetel#1{\advance\tetelc by 1 \altetelc = 0 \alaltetelc = 0
             \vskip 2mm
             \leftline{{\kiscimf\number \tetelc .\enskip #1}}
             \vskip 1.2 mm}

\def\altetel#1{\advance\altetelc by 1 \alaltetelc = 0
               \vskip 1.2mm
               \leftline{{\kiscimf\number\tetelc .\number\altetelc .\enskip #1}}
               \vskip 1.2mm}

\def\alaltetel#1{\advance\alaltetelc by 1
                 \vskip .8mm
                 \leftline{{\kiscimf\number\tetelc .\number\altetelc .\number\alaltetelc .\enskip #1}}
                 \vskip 1.2mm}


% ---- [m..n] u { m - 1 } ----
\def\mn{ [ m .. n ] \cup \{ m - 1 \} }



\cim{Adaptiv fa protokoll}

Egy lehets\'eges megold\'as teh\'at a k\"ovetkez\H o program:



\hoffset=-0.5in  
\smallskip
\Stuki{} 455pt :
  \WHILE  \Stm $TRUE$; DO {
    \Stm $buffer.read\_synchronized()$;
    \Rule
    \Stm $prefix := (<>,0)$;
    \Rule
    \Stm $AKCIO$;
    \Rule
    \IFCASE 40pt : \Stm $atvitel$; => 
      \Stm $SKIP$; |
    \ELSIF 390pt : \Stm $utkozes$; => 
      \Stm $prefix := (<0>,1)$;
      \Rule
      \WHILE  \Stm $prefix.length != 0 $; DO
        \Stm $AKCIO$;
        \Rule
        {\IFCASE 210pt : \Stm $atvitel$; => 
          {\TRUEFALSE 65pt : \Stm $prefix.IP.lov = 0$; => 
            \Stm $prefix.IP.lov$;
            \Stm $:= 1$;
          \ELSE
            \Stm $prefix.visszalep\_IP()$;
            \Rule
            {\TRUEFALSE 40pt : \Stm $prefix.length = 0$; =>
              \Stm $SKIP$;
             \ELSE
             \Stm $prefix.IP.lov := 1$;
             \ENDIF }
           \ENDIF }| 
        \ELSIF 160pt : \Stm $utkozes$; =>
          \Stm $prefix.IP.loext (0)$;
          \Rule
          \Stm $prefix.length$;
          \Stm $:=prefix.length+1 $; |  
        \ENDIF } 
      \ENDDO |
    \ENDIF }
  \ENDDO
\END.

\smallskip
\smallskip

$AKCIO$:
\hoffset=-0.5in  
\smallskip
\Stuki{} 360pt :
\TRUEFALSE 180pt : \Stm $prefix.matched(local.IP) \wedge \neg buffer.empty$; =>
   \Stm $buffer.send\_synchronized()$;
  \ELSE
   \Stm $buffer.wait\_synchronized()$;
  \ENDIF
\END.
    
\end

