\batchmode
\documentclass[twoside,fleqn]{article}
\RequirePackage{ifthen}



\usepackage[spanish]{babel}
\usepackage{isolatin1}
\usepackage{latexsym}
\usepackage{html}
\usepackage{graphicx}
\usepackage{a4wide}
\usepackage{utopia}
\usepackage{listings}
\usepackage{floatflt}

\lstset{visiblespaces=false,mathescape=true,extendedchars=true,commentstyle=\itshape ,language=Modula-2,basicstyle=\sffamily ,keywordstyle=\rmfamily\bfseries ,morekeywords={TASK,BSEMAPHORE,SEMAPHORE,INIT,Wait,Signal,Continue,Delay,COBEGIN,COEND,MONITOR,CONDITION,PUBLIC,STATE,LOOP,CHANNEL,MODEL,Send,Receive,GetChannel,WHEN,SELECT,FORALL}}

%
\renewcommand{\floatpagefraction}{0.9}%
\renewcommand{\floatsep}{0.5cm}%
%
\renewcommand{\textfloatsep}{0.5cm}%

%
\providecommand{\en}{\ensuremath{\rightarrow}}%
\providecommand{\por}{\ensuremath{\times}}%
\providecommand{\nat}{\ensuremath{\mathcal{N}}}%
\providecommand{\bool}{\ensuremath{\mathcal{B}}}%
\providecommand{\real}{\ensuremath{\mathcal{R}}}%
\providecommand{\complex}{\ensuremath{\mathcal{C}}}%
\providecommand{\sal}{\ensuremath{^{sal}}}%
\providecommand{\ent}{\ensuremath{^{ent}}}%
\providecommand{\sep}{\ensuremath{\bullet}}
\topmargin -1cm
\evensidemargin -1cm
\oddsidemargin -1cm
\textwidth 17.5cm
\textheight 25cm

\itemsep -1em
\parsep -2em
\topsep 0pt
\partopsep 0pt
\baselineskip 0pt


\usepackage[dvips]{color}


\pagecolor[gray]{.7}

\usepackage[latin1]{inputenc}



\makeatletter

\makeatletter
\count@=\the\catcode`\_ \catcode`\_=8 
\newenvironment{tex2html_wrap}{}{}%
\catcode`\<=12\catcode`\_=\count@
\newcommand{\providedcommand}[1]{\expandafter\providecommand\csname #1\endcsname}%
\newcommand{\renewedcommand}[1]{\expandafter\providecommand\csname #1\endcsname{}%
  \expandafter\renewcommand\csname #1\endcsname}%
\newcommand{\newedenvironment}[1]{\newenvironment{#1}{}{}\renewenvironment{#1}}%
\let\newedcommand\renewedcommand
\let\renewedenvironment\newedenvironment
\makeatother
\let\mathon=$
\let\mathoff=$
\ifx\AtBeginDocument\undefined \newcommand{\AtBeginDocument}[1]{}\fi
\newbox\sizebox
\setlength{\hoffset}{0pt}\setlength{\voffset}{0pt}
\addtolength{\textheight}{\footskip}\setlength{\footskip}{0pt}
\addtolength{\textheight}{\topmargin}\setlength{\topmargin}{0pt}
\addtolength{\textheight}{\headheight}\setlength{\headheight}{0pt}
\addtolength{\textheight}{\headsep}\setlength{\headsep}{0pt}
\setlength{\textwidth}{451pt}
\setlength{\textheight}{554pt}
\newwrite\lthtmlwrite
\makeatletter
\let\realnormalsize=\normalsize
\global\topskip=2sp
\def\preveqno{}\let\real@float=\@float \let\realend@float=\end@float
\def\@float{\let\@savefreelist\@freelist\real@float}
\def\liih@math{\ifmmode$\else\bad@math\fi}
\def\end@float{\realend@float\global\let\@freelist\@savefreelist}
\let\real@dbflt=\@dbflt \let\end@dblfloat=\end@float
\let\@largefloatcheck=\relax
\let\if@boxedmulticols=\iftrue
\def\@dbflt{\let\@savefreelist\@freelist\real@dbflt}
\def\adjustnormalsize{\def\normalsize{\mathsurround=0pt \realnormalsize
 \parindent=0pt\abovedisplayskip=0pt\belowdisplayskip=0pt}%
 \def\phantompar{\csname par\endcsname}\normalsize}%
\def\lthtmltypeout#1{{\let\protect\string \immediate\write\lthtmlwrite{#1}}}%
\newcommand\lthtmlhboxmathA{\adjustnormalsize\setbox\sizebox=\hbox\bgroup\kern.05em }%
\newcommand\lthtmlhboxmathB{\adjustnormalsize\setbox\sizebox=\hbox to\hsize\bgroup\hfill }%
\newcommand\lthtmlvboxmathA{\adjustnormalsize\setbox\sizebox=\vbox\bgroup %
 \let\ifinner=\iffalse \let\)\liih@math }%
\newcommand\lthtmlboxmathZ{\@next\next\@currlist{}{\def\next{\voidb@x}}%
 \expandafter\box\next\egroup}%
\newcommand\lthtmlmathtype[1]{\gdef\lthtmlmathenv{#1}}%
\newcommand\lthtmllogmath{\lthtmltypeout{l2hSize %
:\lthtmlmathenv:\the\ht\sizebox::\the\dp\sizebox::\the\wd\sizebox.\preveqno}}%
\newcommand\lthtmlfigureA[1]{\let\@savefreelist\@freelist
       \lthtmlmathtype{#1}\lthtmlvboxmathA}%
\newcommand\lthtmlpictureA{\bgroup\catcode`\_=8 \lthtmlpictureB}%
\newcommand\lthtmlpictureB[1]{\lthtmlmathtype{#1}\egroup
       \let\@savefreelist\@freelist \lthtmlhboxmathB}%
\newcommand\lthtmlpictureZ[1]{\hfill\lthtmlfigureZ}%
\newcommand\lthtmlfigureZ{\lthtmlboxmathZ\lthtmllogmath\copy\sizebox
       \global\let\@freelist\@savefreelist}%
\newcommand\lthtmldisplayA{\bgroup\catcode`\_=8 \lthtmldisplayAi}%
\newcommand\lthtmldisplayAi[1]{\lthtmlmathtype{#1}\egroup\lthtmlvboxmathA}%
\newcommand\lthtmldisplayB[1]{\edef\preveqno{(\theequation)}%
  \lthtmldisplayA{#1}\let\@eqnnum\relax}%
\newcommand\lthtmldisplayZ{\lthtmlboxmathZ\lthtmllogmath\lthtmlsetmath}%
\newcommand\lthtmlinlinemathA{\bgroup\catcode`\_=8 \lthtmlinlinemathB}
\newcommand\lthtmlinlinemathB[1]{\lthtmlmathtype{#1}\egroup\lthtmlhboxmathA
  \vrule height1.5ex width0pt }%
\newcommand\lthtmlinlineA{\bgroup\catcode`\_=8 \lthtmlinlineB}%
\newcommand\lthtmlinlineB[1]{\lthtmlmathtype{#1}\egroup\lthtmlhboxmathA}%
\newcommand\lthtmlinlineZ{\egroup\expandafter\ifdim\dp\sizebox>0pt %
  \expandafter\centerinlinemath\fi\lthtmllogmath\lthtmlsetinline}
\newcommand\lthtmlinlinemathZ{\egroup\expandafter\ifdim\dp\sizebox>0pt %
  \expandafter\centerinlinemath\fi\lthtmllogmath\lthtmlsetmath}
\newcommand\lthtmlindisplaymathZ{\egroup %
  \centerinlinemath\lthtmllogmath\lthtmlsetmath}
\def\lthtmlsetinline{\hbox{\vrule width.1em \vtop{\vbox{%
  \kern.1em\copy\sizebox}\ifdim\dp\sizebox>0pt\kern.1em\else\kern.3pt\fi
  \ifdim\hsize>\wd\sizebox \hrule depth1pt\fi}}}
\def\lthtmlsetmath{\hbox{\vrule width.1em\kern-.05em\vtop{\vbox{%
  \kern.1em\kern0.75 pt\hbox{\hglue.17em\copy\sizebox\hglue0.75 pt}}\kern.3pt%
  \ifdim\dp\sizebox>0pt\kern.1em\fi \kern0.75 pt%
  \ifdim\hsize>\wd\sizebox \hrule depth1pt\fi}}}
\def\centerinlinemath{%
  \dimen1=\ifdim\ht\sizebox<\dp\sizebox \dp\sizebox\else\ht\sizebox\fi
  \advance\dimen1by.5pt \vrule width0pt height\dimen1 depth\dimen1 
 \dp\sizebox=\dimen1\ht\sizebox=\dimen1\relax}

\def\lthtmlcheckvsize{\ifdim\ht\sizebox<\vsize 
  \ifdim\wd\sizebox<\hsize\expandafter\hfill\fi \expandafter\vfill
  \else\expandafter\vss\fi}%
\providecommand{\selectlanguage}[1]{}%
\makeatletter \tracingstats = 1 


\begin{document}
\pagestyle{empty}\thispagestyle{empty}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength hsize=\the\hsize}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength vsize=\the\vsize}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength hoffset=\the\hoffset}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength voffset=\the\voffset}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength topmargin=\the\topmargin}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength topskip=\the\topskip}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength headheight=\the\headheight}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength headsep=\the\headsep}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength parskip=\the\parskip}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength oddsidemargin=\the\oddsidemargin}\lthtmltypeout{}%
\makeatletter
\if@twoside\lthtmltypeout{latex2htmlLength evensidemargin=\the\evensidemargin}%
\else\lthtmltypeout{latex2htmlLength evensidemargin=\the\oddsidemargin}\fi%
\lthtmltypeout{}%
\makeatother
\setcounter{page}{1}
\onecolumn

% !!! IMAGES START HERE !!!

\stepcounter{section}
{\newpage\clearpage
\lthtmlpictureA{tex2html_wrap163}%
\includegraphics[width=0.5\textwidth]{im/estacion.eps}%
\lthtmlpictureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting144}%
\begin{lstlisting}{}
Sensor.EsperarPasoTren(NumeroEstacion: TipoNumEst)
(* Se bloquea hasta que se detecte el paso del último vagón de un tren*)
(* por la vía que sale de la estación NumeroEstacion.                 *)
(* Puede consultarse concurrentemente el estado de varios sensores.   *)
\par Semaforo.DarSalida(NumeroEstacion: TipoNumEst;
                   NumeroVia:      TipoNumVia);
(* Pone a verde el semáforo de la vía NumeroVia en la estación        *)
(* NumeroEstacion y lo vuelve a poner a rojo tras el tiempo necesario *)
(* para que el tren arranque (este tiempo es mucho menor que el que   *)
(* emplea el tren en llegar al cruce).  No pueden realizarse          *)
(* concurrentemente operaciones sobre semáforos de la misma estación. *) 
(* Es bloqueante.                                                     *) 
\par Terminal.LeerPeticion(    NumeroEstacion: TipoNumEst;
                      VAR Clase:          TipoTren;
                      VAR NumeroVia:      TipoNumVia);
(* Lee una petición de salida de la estación NumeroEstacion.  La vía  *)
(* en la que está el tren que quiere salir se devuelve en NumeroVia   *)
(* y la clase de tren se devuelve en Clase.  Es bloqueante.           *)
\end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting147}%
\begin{lstlisting}{}
  TYPE TipoNumEst = [1..2];
       TipoNumVia = 1..MaxVias;
       TipoTren   = (urgente, normal);
\end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline155}%
$n$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting214}%
\begin{lstlisting}{}
TASK AdmisionPeticion(i)
  LOOP
    Terminal.LeerPeticion(i, ClaseTren, Via);
    Estacion.TrenListo(i, ClaseTren, Via);
  END;
END;
  \end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting220}%
\begin{lstlisting}{}
TASK ControladorCruce;
  LOOP
    Estacion.PermisoSalirEst(i, Via);
    Semaforo.DarSalida(i, Via);
    Sensor.EsperarPasoTren(i);
  END;
END;
  \end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting228}%
\begin{lstlisting}{}
TASK AdmisionPeticion(i)
  LOOP
    Terminal.LeerPeticion(i, ClaseTren, Via);
    Estacion.TrenListo(i, ClaseTren, Via);
    Estacion.PermisoSalirEst(i, Via);
    Semaforo.DarSalida(i, Via);
    Sensor.EsperarPasoTren(i);
  END;
END;
  \end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{section}
{\newpage\clearpage
\lthtmlpictureA{tex2html_wrap510}%
\includegraphics[width=0.9\textwidth]{im/recurso-estacion}%
\lthtmlpictureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting300}%
\begin{lstlisting}{}
TASK ControladorCruce(i)
  LOOP
    Sensor.EsperarPasoTren(i);
    Estacion.YaPasoTren;
  END;
END;
  \end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting307}%
\begin{lstlisting}{}
TASK ControladorSalida(i)
  LOOP
    Estacion.PermisoSalirEst(i, Via);
    Semaforo.DarSalida(i, Via);
  END;
END;
    \end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline450}%
\ensuremath{\times}%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline466}%
$\mathsf{booleano}$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline468}%
$\mathsf{Secuencia(Secuencia(\emph{TipoVia}))}$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline472}%
$|$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline474}%
$\forall t \in\emph{TipoControlEstacion} \ensuremath{\bullet}(\mathsf{Longitud}(t.ColaUrg) = 2 \;\wedge\mathsf{Longitud}(t.ColaNorm) = 2)$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline476}%
$Cnt.CruceOcupado^{sal} = \mathsf{falso} \; \wedge$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline478}%
$\mathsf{Longitud}(Cnt.ColaUrg^{sal}(1)) = 0 \; \wedge\mathsf{Longitud}(Cnt.ColaUrg^{sal}(2)) = 0 \; \wedge$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline480}%
$\mathsf{Longitud}(Cnt.ColaNorm^{sal}(1)) = 0 \; \wedge\mathsf{Longitud}(Cnt.ColaNorm^{sal}(2)) = 0$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline482}%
$Cnt^{sal} = Cnt^{ent} \; \backslash  $%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline484}%
$(Tipo = Urgente \rightarrow \emph{Insertar}(Cnt.ColaUrg(Est),Via)) \; \wedge$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline486}%
$(Tipo = Normal \rightarrow  \emph{Insertar}(Cnt.ColaNorm(Est),Via))$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline488}%
$\emph{Insertar}(s, e) = (s^{sal} = s^{ent} \backslash\mathsf{Longitud}(s^{sal}) = \mathsf{Longitud}(s^{ent}) + 1 \wedge s^{sal}(\mathsf{Longitud}(s^{sal})) = e)$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline490}%
$(HayUrgentes \; \vee HayNormales) \wedge \negCnt.CruceOcupado^{ent}$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline492}%
$Cnt^{sal} = Cnt^{ent} \; \backslash \;Cnt.CruceOcupado^{sal} = \mathsf{verdad} \;\wedge (HayUrgentes\rightarrow \emph{Retirar}(Cnt.ColaUrg(Est), Via))$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline494}%
$(\neg HayUrgentes \wedge HayNormales \rightarrow\emph{Retirar}(Cnt.ColaNormal(Est), Via))$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline496}%
$LongUrg = \mathsf{Longitud}(Cnt.ColaUrg^{ent}(Est)) \;\wedge LongNorm = \mathsf{Longitud}(Cnt.ColaNormal^{ent}(Est)) \; \wedge$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline498}%
$HayUrgentes = (LongUrg > 0) \; \wedge HayNormales = (LongNorm >0)\; \wedge$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline500}%
$\emph{Retirar}(s, e) = (e^{sal} = s^{ent}(1) \wedgel = \mathsf{Longitud}(s^{ent}) \wedge \mathsf{Longitud}(s^{sal}) =  l- 1 \wedge  s^{sal}(1..l-1) = s^{ent}(2..l))$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline502}%
$Cnt^{sal} = Cnt^{ent} \backslashCnt.CruceOcupado^{sal} = \mathsf{falso}$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{lstlisting551}%
\begin{lstlisting}{}
  CONST
       NUMESTACIONES = 2;
       MAXVIAS = 2;
\par (* DECLARACION DE TIPOS *)
\par TYPE
       TipoVacio = CARDINAL;
       TipoNumEst = [1..NUMESTACIONES];
       TipoVia = CARDINAL;
       TipoTren = (urgente, normal);
       TipoSalida = RECORD
                         numestacion: TipoNumEst;
                         numvia: TipoVia;
                         tipotren: TipoTren;
                    END;
\par VAR
       (* DECLARACION DE LOS CANALES *)
       canTrenListo: CHANNEL; (* OF TipoSalida *)
       canPermisoSalirEst: ARRAY [1..NUMESTACIONES] OF CHANNEL; (* OF TipoVacio *)
       canYaPasoTren: CHANNEL; (* OF TipoVacio *)
       canDevVia: ARRAY [1..NUMESTACIONES] OF CHANNEL; (* OF TipoVia *)
\par (* CODIGO QUE IMPLEMENTA EL RECURSO ACTIVO *)
\par TASK ControlEstacion;
   VAR
     (* Estado del recurso *)
       cruceocupado: BOOLEAN;
       colaurg, colanorm: ARRAY TipoNumEst OF COLA.TipoCola;
     (* variables auxiliares *)
       i: TipoNumEst;
       viaquesale: TipoVia;
       datossalida: TipoSalida;
       vacio: TipoVacio;
\par BEGIN
    (* Inicializacion del recurso *)
\par GetChannel (canTrenListo);
    GetChannel (canYaPasoTren);
    FOR i := 1 TO NUMESTACIONES DO
        GetChannel (canPermisoSalirEst[i]);
        COLA.Vacia(colaurg[i]);
        COLA.Vacia(colanorm[i]);
    END;
    cruceocupado := FALSE;
\par LOOP
       SELECT
          (* Canal para la operacion YaPasoTren *)
\par WHEN cruceocupado, Receive (canYaPasoTren, vacio) DO
              cruceocupado := FALSE;
\par (*
             Para la operacion PermisoSalirEst se emplean dos canales,
             uno para cada estacion (1 y 2). Dado que CCMODULA elige de
             forma equitativa entre todos los canales abiertos en una
             espera selectiva, se asegura la equidad entre las dos estaciones,
             y por tanto se evita la inanici¢n de una de las estaciones.
          *)
\par WHEN NOT (cruceocupado) AND (NOT (COLA.EsVacia(colaurg[1])) OR
          NOT (COLA.EsVacia(colanorm[1]))),
                    Receive (canPermisoSalirEst[1], vacio) DO
              cruceocupado := TRUE;
\par (* si hay trenes urgentes esperando en esta estacion,
                 deben salir antes *)
              IF NOT(COLA.EsVacia(colaurg[1])) THEN
                 COLA.Primero(colaurg[1], viaquesale);
                 COLA.Borrar(colaurg[1]);
              ELSE
                 COLA.Primero(colanorm[1], viaquesale);
                 COLA.Borrar(colanorm[1]);
              END;
\par (* se devuelve la via del tren que va a salir desde
                 la estacion 1 *)
              Send (canDevVia[1], viaquesale);
\par WHEN NOT (cruceocupado) AND (NOT (COLA.EsVacia(colaurg[2])) OR
          NOT (COLA.EsVacia(colanorm[2]))),
                    Receive (canPermisoSalirEst[2], vacio) DO
              cruceocupado := TRUE;
\par (* si hay trenes urgentes esperando en esta estacion,
                 deben salir antes *)
              IF NOT(COLA.EsVacia(colaurg[2])) THEN
                 COLA.Primero(colaurg[2], viaquesale);
                 COLA.Borrar(colaurg[2]);
              ELSE
                 COLA.Primero(colanorm[2], viaquesale);
                 COLA.Borrar(colanorm[2]);
              END (* IF *);
              (* se devuelve la via del tren que va a salir desde
                 la estacion 2 *)
              Send (canDevVia[2], viaquesale);
\par (* Canal para la operacion TrenListo *)
\par WHEN TRUE, Receive (canTrenListo, datossalida) DO
              IF datossalida.tipotren = urgente THEN
                 COLA.Insertar(colaurg[datossalida.numestacion], datossalida.numvia);
              ELSE
                 COLA.Insertar(colanorm[datossalida.numestacion], datossalida.numvia);
              END;
\par END (* SELECT *)
    END (* LOOP *)
  END ControlEstacion;
\par (* Codigo de las operaciones del recurso *)
\par PROCEDURE TrenListo (i: TipoNumEst; clasetren: TipoTren; via: TipoVia);
  VAR
    datossalida: TipoSalida;
  BEGIN
      datossalida.numestacion := i;
      datossalida.numvia := via;
      datossalida.tipotren := clasetren;
      Send (canTrenListo, datossalida);
  END TrenListo;
\par PROCEDURE YaPasoTren;
  VAR
    vacio: CARDINAL;
  BEGIN
      Send (canYaPasoTren, vacio); (* se manda una sennal *)
  END YaPasoTren;
\par PROCEDURE PermisoSalirEstacion (i: TipoNumEst; VAR via: TipoVia);
  VAR
    vacio: CARDINAL;
  BEGIN
      Send (canPermisoSalirEst[i], vacio);
      Receive (canDevVia[i], via);
  END PermisoSalirEstacion;
\par\end{lstlisting}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}


\end{document}
