continuous-integration/drone/push Build is passing
Reorganize all source files into a hierarchical namespace structure with dot-separated unit names matching directory paths. Major changes: - src/prog/ -> src/app/ (app.*.pas) - src/fault/ -> src/arch/x86/fault/ (arch.x86.fault.*.pas) - src/isr/ -> src/arch/x86/isr/ (arch.x86.isr.*.pas) - src/include/ -> src/core/ (core.*.pas) + src/arch/x86/ - src/driver/ subtree reorganized with driver.* namespace prefixes - src/driver/storage/con/ -> src/driver/storage/ctl/ (Windows reserved name fix) - src/driver/storage/ split into con(ctl)/fs/vol/ subdirectories - src/driver/net/ flattened from l1-l5 layers to driver.net.*.pas - kernel.pas -> asuro.pas, faults.pas -> arch.x86.faults.pas - stdio.pas/syslog.pas -> io/io.stdio.pas, io/io.syslog.pas - processmanager.pas -> proc/proc.mgr.pas - lmemorymanager.pas -> memory/memory.heap.pas - Build scripts moved to toolchain/ - Added compat/ shims for lmemorymanager and types - Added doc/namespace.md tracking the refactor 197 files changed, 6292 insertions(+), 5526 deletions(-)
61 lines
1.4 KiB
ObjectPascal
61 lines
1.4 KiB
ObjectPascal
{
|
|
TestProcs - Temporary test processes for validating preemptive scheduling.
|
|
|
|
Two processes that each print a message once per second via io.syslog,
|
|
demonstrating concurrent preemptive execution.
|
|
|
|
@author(Kieron Morris <[email protected]>)
|
|
}
|
|
unit proc.testprocs;
|
|
|
|
interface
|
|
|
|
uses
|
|
proc.types, proc.mgr, io.syslog, arch.x86.bda;
|
|
|
|
procedure init;
|
|
|
|
implementation
|
|
|
|
{ Simple busy-wait sleep: spin-yields until approx 'ticks' timer ticks
|
|
have elapsed (timer runs at ~1024 Hz, so 1024 ticks ~ 1 second). }
|
|
procedure sleep_ticks(ticks : uint16);
|
|
var
|
|
start, now, elapsed : uint16;
|
|
begin
|
|
start := BDA^.Ticks;
|
|
repeat
|
|
proc_yield;
|
|
now := BDA^.Ticks;
|
|
if now >= start then
|
|
elapsed := now - start
|
|
else
|
|
elapsed := (65535 - start) + now + 1; { handle uint16 wrap }
|
|
until elapsed >= ticks;
|
|
end;
|
|
|
|
procedure program1(ctx : PProcessContext);
|
|
begin
|
|
while ctx^.PendingMsg <> smTerminate do begin
|
|
io.syslog.logln('PROC1', 'Hello from program 1');
|
|
sleep_ticks(1024);
|
|
end;
|
|
end;
|
|
|
|
procedure program2(ctx : PProcessContext);
|
|
begin
|
|
while ctx^.PendingMsg <> smTerminate do begin
|
|
io.syslog.logln('PROC2', 'Hello from program 2');
|
|
sleep_ticks(1024);
|
|
end;
|
|
end;
|
|
|
|
procedure init;
|
|
begin
|
|
proc.mgr.create('testproc1', @program1, nil, 1);
|
|
proc.mgr.create('testproc2', @program2, nil, 1);
|
|
io.syslog.logln('TESTPROCS', 'Two test processes created.');
|
|
end;
|
|
|
|
end.
|