Организация параллельной работы нескольких процессов. Описание процедур, страница 3

procedure my_buffer;

var my_buffer_i:byte;

begin

gotoxy(9,21);

textcolor(lightred);

write(round(higggh/size*100):3,'%');

gotoxy(14,21);

textcolor(red);

for my_buffer_i:=1 to round(higggh/size*100) do

if my_buffer_i mod 4=0 then write(#178);

for my_buffer_i:=100 downto round(higggh/size*100) do

if (my_buffer_i mod 4=0)and(higggh<>size) then Write(' ');

end;

{===========================================================================}

procedure my_producter;

Var J,jj: Word;

begin

if Not On[4] Then begin

gotoxy(12,13);

textcolor(7);

write('Standby':7);

Exit;

end;

if (Higggh=Size) then begin

gotoxy(12,13);

textcolor(7);

write('Waiting':7);

exit;

end;

gotoxy(12,13);

textcolor(7);

write('Active':7);

If On[5] Then begin

gotoxy(39,13);

textcolor(7);

write('Waiting':7);

end;

For J:=2 To I-1  Do

If (I Mod J) = 0 Then

Begin

Inc(I);

Exit;

End;

if i>999 then i:=1;

Inc(Higggh);

For J:= Higggh DownTo 2 Do

begin

Buf[J]:= Buf[J-1];

Buf[J-1]:=0;

end;

Buf[1]:= I;

textcolor(white);

output1;

Write(i:3);

Inc(I);

textcolor(2);

output2;

write(' ':3);

end;

{===========================================================================}

procedure my_consumer;

Var I: Word;

begin

gotoxy(39,13);

textcolor(7);

write('Active':7);

textcolor(5);

If Not On[5] Then begin

gotoxy(39,13);

textcolor(7);

write('Standby':7);

Exit;

end;

For I:= 1 To s_end Do

Begin

If Higggh = 0 Then begin

gotoxy(39,13);

textcolor(7);

write('Waiting':7);

Exit;

end;

If On[4] Then begin

gotoxy(12,13);

textcolor(7);

write('Waiting':7);

end;

textcolor(lightred);

output2;

Write(Buf[Higggh]:3);

Buf[Higggh]:=0;

textcolor(3);

output1;

Write(0:3);

Dec(Higggh);

End;

end;

{===========================================================================}

procedure onexit;

begin

gotoxy(12,13);

textcolor(7);

write('Standby':7);

On[5]:=true;

s_end:=42;

my_consumer;

my_buffer;

gotoxy(39,13);

textcolor(7);

write('Standby':7);

gotoxy(55,13);

textcolor(13);

write(':--');

gotoxy(26,13);

textcolor(13);

write(':--');

Exxxxxit:=true;

end;

{===========================================================================}

Procedure my_clock;

var

OldX,OldY:integer;

begin

Counter:=Counter+1;

ReloadCounter:=ReloadCounter+1;

if Counter>=18.2 then

begin

Inc(Sec);

Counter:=Counter-18.2;

end;

if Sec=60 then

begin

Inc(Min);

Sec:=0;

end;

If Min=60 then

begin

Inc(Hour);

Min:=0;

end;

If Hour=24 then

begin

Hour:=0;

end;

If (ReloadCounter>=ReloadSize*18.2) then

begin

OldX:=WhereX;

OldY:=WhereY;

GotoXY(XC,YC);

If Not On[1] Then Exit else

begin

textcolor(10);

if Hour<10 then write('0',Hour,':')

else write(Hour,':');

if Min<10 then write('0',Min,':')

else write(Min,':');

if Sec<10 then write('0',Sec)

else write(Sec);

end;

ReloadCounter:=ReloadCounter-ReloadSize*18.2;

GotoXY(OldX,OldY);

end;

end;

{===========================================================================}

procedure my_letalka;

begin

If Not On[6] Then Exit;

count:=count+1;

if count=2 then

begin

count:=0;

memory[y][x].symbol:=mem_old[y][x].symbol;

memory[y][x].attr:=mem_old[y][x].attr;

if t2>=n2 then

begin t2:=0;x:=x+vx;

end;

if t3>=n3 then

begin t3:=0;y:=y+vy;

end;

if x+vx>=59 then vx:=-1;

if x+vx<=1 then vx:=1;

if y+vy>=12 then vy:=-1;

if y+vy<=3 then vy:=1;

mem_old[y][x].symbol:=memory[y][x].symbol;

mem_old[y][x].attr:=memory[y][x].attr;

memory[y][x].symbol:='[1]';

memory[y][x].attr:=random(15);

end;

end;

{===========================================================================}

procedure my_stroka;