|
Vector : TVector; -- de TDato
Gestor : AccesoVector;
...
task type Intercambiador (I : Indice);
task body Intercambiador is
Intermedio : TDato;
Fin, Permutado : Boolean;
begin
loop
if I mod 2 = 0 then
Gestor.InicioEtapaPar (Fin);
else
Gestor.InicioEtapaImpar (Fin);
end if;
if not Fin then
if Vector (I) > Vector (I+1) then
Intermedio := Vector (I);
Vector (I) := Vector (I+1);
Vector (I+1) := Intermedio;
Permutado := True;
else
Permutado := False;
end if;
if I mod 2 = 0 then
Gestor.FinEtapaPar (Permutado);
else
Gestor.FinEtapaImpar (Permutado);
end if;
end if;
exit when Fin;
end loop;
end Intercambiador;
|
|
task type TProductor;
task body TProductor is
VectorLocal : TVector;
begin
<obtener VectorLocal>
for I in Indice loop
Vector (I) := VectorLocal (I);
end loop;
Gestor.IniciarOrdenacion ();
end TProductor;
task type TConsumidor;
task body TConsumidor is
VectorLocal : TVector;
begin
Gestor.EsperarFinOrdenacion ();
for I in Indice loop
VectorLocal (I) := Vector (I);
end loop;
<procesar VectorLocal>
end TConsumidor;
Productor : TProductor;
Consumidor : TConsumidor;
type TIntercambiador is access Intercambiador;
Intercambiadores : array Indice of TIntercambiador;
|
|