program Test;

{ Program demonstrujici funkci realtimoveho programu.
}

uses
{$ifdef MCP}
  RtcTime,
{$endif}
  NumToStr,
  Crt,
  Dos,
  Kernel;


{$F+}

procedure Process;
var
  a:integer;
begin
     Start('Process', 8000, 80, 1);
     Exit;
     a:=0;
     repeat
       writeln('Vypis:=', a);
       Wait(1);
{       Delay(500);}
       Inc(a);
     until false;
end {ProcTicks};


procedure MyExitProc; far;
begin
  gotoxy(1,24);
  if ExitCode<>0 then writeln('ExitProc: ', ExitCode, ' - address: ', PtrToStr(ErrorAddr));
{$ifdef VerMC}
  repeat until false;
{$else}
  halt(ExitCode);
{$endif}
end;


var
  Counter:Integer;
  HeapSize:LongInt;

begin
  HeapSize:=MemAvail;
  writeln('HeapSize:=', HeapSize);

  ExitProc := @MyExitProc;

  ClrScr;
  Writeln('Spusteni jadra');

  { inicializace os ReTOS }
  StartMain(200, 254);
  InitInterruptStack(1,254);
  StartTimeSlicing(8);

  Process;

  Writeln('Spusteni dalsich procesu');

  repeat
    Writeln('Make ', Counter);
    Inc(Counter);
    wait(10);
  until keypressed;
  readkey;

  Abort('*');

  TerminateMain;                        { ukonceni programu         }

  writeln('HeapSize:=', HeapSize, ' x ', MemAvail, ' - rozdil:', HeapSize-MemAvail);
end.