【列表5.11】 priTest程序代码。
{
priTest - illustrate process priorities
}
program priTest;
{$APPTYPE CONSOLE}
uses SysUtils, Libc;
var
forkRslt : __pid_t;
i,
LoopCount : integer;
s : String;
begin
forkRslt := fork;
if forkRslt = 0 then
begin
s := 'Child';
end
else if forkRslt > 0 then
begin
s := 'Parent';
// set child's priority
if setpriority (PRIO_PROCESS, forkRslt, 10)= -1 then
perror ('Error setting priority');
end
else
begin
perror ('Error in fork');
exit;
end;
LoopCount := 0;
repeat
WriteLn (Format ('%s=%d', [s, LoopCount]));
Inc (LoopCount);
//little delay loop
for i:=1 to 10000000 do ;
until false;
end.