- Program DOS altında çok işlemli (multi-task) uygulamanın mantığını kavrayabilmek için geliştirilmiştir.
İçinde eş zamanlı çalışan iki işlem barındırmaktadır. Bu işlemler çalışırken birbirini etkilememektedir.
Çalıştırıcı olarak int 1Ch seçilmiştir. Bu sebepten çalışma frekansı 18.2pps\\\\\\\\\\\\\'dir.
Temel mantık alınarak çok daha farklı çözümler üretilebilir.
Başarılar.
uses Crt, DOS;
{ H. Emre KARTAL }
{ 25.07.1998 }
type
TProcedure = Pointer;
PProcess = ^TProcess;
TProcess = packed record
Next: PProcess;
Proc: TProcedure;
ID: Byte;
end;
var
ID: Byte absolute $40:$6C;
function AddProcess(Proc: TProcedure; const Next: PProcess): PProcess;
var
P: PProcess;
begin
GetMem(P, SizeOf(TProcess));
P^.ID := ID;
P^.Proc := Proc;
P^.Next := Next;
ProcessEkle := P;
end;
procedure ClearProcessList(var ProcessList: PProcess);
var
P: PProcess;
begin
P := ProcessList;
while (P <> nil) do
begin
ProcessList := P^.Sonraki;
FreeMem(P, SizeOf(TProcess));
P := ProcessList;
end;
ProcessList := nil;
end;
{$F+}
var
ProcessList: PProcess;
Int1C: Pointer;
procedure SysProcessList(Flags, CS, IP, AX, BX, CX, DX, SI, DI, DS, ES, BP: Word); interrupt;
var
P: PProcess;
ID: Byte absolute $40:$6C;
begin
SetIntVec($1C, Int1C);
P := ProcessList;
while (P <> nil) do
begin
if (P^.ID = ID) then
asm
{
P^.Proc
}
MOV ES,[ P + 2 ].WORD
MOV DI,[ P ].WORD
CALL DWORD PTR ES:DI
end;
P := P^.Sonraki;
end;
SetIntVec($1C, @SysProcessList);
end;
{$F-}
procedure _1;
begin
WriteLn('1. proc.');
end;
procedure _2;
begin
WriteLn('2. proc.');
end;
begin
ProcessList := ProcessAdd(@_1, ProcessAdd(@_2, nil));
GetIntVec($1C, Int1C);
SetIntVec($1C, @SysProcessList);
repeat until (KeyPressed);
SetIntVec($1C, Int1C);
ClearProcessList(ProcessList);
end.
HackroForum