feature: preemptive process management - implementation progress

Implement a preemptive multitasking system for the Asuro kernel.

Context Switching & Scheduling:
- Custom IRQ0 ISR (contextswitcher.pas) with PUSHAD/POPAD ESP-swap
- Round-robin scheduler with priority-based quantum
- Process table using DList of PProcessContext pointers
- Idle process (PID 0) replaces kernel HLT loop

Process Lifecycle:
- create/kill/terminate/sendMessage API (processmanager.pas)
- Process states: Created, Running, Ready, Suspended, Awaiting,
  Finished, Error
- Parent-child tracking (ParentID, smChildExited notification on reap)
- proc_yield, proc_sleep_ms, proc_await, proc_suspend, proc_exit

Resource Binding & Cleanup:
- Per-process resource list
  (bindResource/unbindResource/unbindAllResources)
- TCP sockets auto-bound to owning process (OwnerPID on TTCPSocket)
- socket_cleanup + auto-unbind in DestroySocket

VTerminal Refactor:
- Multi-instance design (heap-allocated TVTermState per terminal)
- Foreground process with incremental stdout/stderr drain via LVGL timer
- Ctrl+C kills foreground process (killForeground)
- Per-terminal CWD, dir stack, FS builtins (CD/LS/PUSHD/POPD)
- Background job support (& suffix, JOBS/FG commands)
- Command history (Up/Down arrow)

Command Consolidation:
- 14 commands extracted from 9 units into centralized progmanager.pas
- Command procedures exported in host unit interfaces
- E1000/TRACER/stdio builtins kept in-place (conditional/circular)

New Units:
- src/include/proctypes.pas — process type definitions
- src/processmanager.pas — core process manager
- src/prog/ping.pas — standalone ICMP ping process
- src/prog/testcmd.pas — test command (proc_sleep_ms demo)
- src/testprocs.pas — process subsystem smoke tests

Misc:
- ICMP callbacks gain userData parameter for concurrency-safe ping
- CLI/STI guards on kalloc/kfree (lmemorymanager.pas)
- LV_KEY_CTRLC constant + Ctrl+C interception in LVGL keyboard hook
- Window owner PID tracking (windows.pas)
- ISR_32 gate override support (isrmanager.pas)
This commit is contained in:
t3hn3rd committed 2026-03-04 19:42:33 +00:00
1 parent fb675a2299
commit de6fde05cc
23 files changed
+2309 -376

No files matched your search

+1 -1
View File
@@ -112,6 +112,7 @@ function get_device_list() : PLinkedListBase;
procedure register_filesystem(filesystem : PFilesystem);
procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
procedure disk_command(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
//function writeNewFile(fileName : pchar; extension : pchar; buffer : puint32; size : uint32) : uint32;
//function readFile(fileName : pchar; extension : pchar; buffer : puint32; byteCount : puint32) : puint32;
@@ -231,7 +232,6 @@ begin
setworkingdirectory('.');
storageDevices:= ll_new(sizeof(TStorage_Device));
fileSystems:= ll_New(sizeof(TFilesystem));
stdio.registerCommand('DISK', @disk_command, 'Disk utility');
pop_trace();
end;
+67 -5
View File
@@ -104,6 +104,10 @@ function GetDirectories(Handle : uint32; Path : pchar) : PHashMap;
function PathValid(Path : pchar) : TIsPathValid;
function changeDirectory(Path : pchar) : TIsPathValid;
function getWorkingDirectory : pchar;
function makeAbsolutePathFrom(Path : pchar; BaseDir : pchar) : pchar;
function resolvePathFrom(Path : pchar; BaseDir : pchar) : TIsPathValid;
function GetDirectoryListingFrom(Path : pchar; BaseDir : pchar) : PHashMap;
function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid;
//VFS Functions
function newVirtualDirectory(Path : pchar) : TError;
@@ -608,6 +612,67 @@ begin
tracer.push_trace('vfs.getWorkingDirectory.exit');
end;
function makeAbsolutePathFrom(Path : pchar; BaseDir : pchar) : pchar;
var
AbsPath : pchar;
TempPath : pchar;
begin
if Path[0] = '/' then
AbsPath := stringCopy(Path)
else begin
if BaseDir[StringSize(BaseDir)-1] <> '/' then
TempPath := StringConcat(BaseDir, '/')
else
TempPath := stringCopy(BaseDir);
AbsPath := StringConcat(TempPath, Path);
kfree(void(TempPath));
end;
makeAbsolutePathFrom := AbsPath;
end;
function resolvePathFrom(Path : pchar; BaseDir : pchar) : TIsPathValid;
var
TempPath : pchar;
AbsPath : pchar;
begin
TempPath := makeAbsolutePathFrom(Path, BaseDir);
AbsPath := evaluatePath(TempPath);
kfree(void(TempPath));
resolvePathFrom := PathValid(AbsPath);
kfree(void(AbsPath));
end;
function GetDirectoryListingFrom(Path : pchar; BaseDir : pchar) : PHashMap;
var
TempPath : pchar;
AbsPath : pchar;
begin
TempPath := makeAbsolutePathFrom(Path, BaseDir);
AbsPath := evaluatePath(TempPath);
kfree(void(TempPath));
GetDirectoryListingFrom := GetDirectoryListing(AbsPath);
kfree(void(AbsPath));
end;
function changeDirectoryFrom(Path : pchar; BaseDir : pchar; var NewDir : pchar) : TIsPathValid;
var
TempPath : pchar;
AbsPath : pchar;
Validity : TIsPathValid;
begin
TempPath := makeAbsolutePathFrom(Path, BaseDir);
AbsPath := evaluatePath(TempPath);
kfree(void(TempPath));
Validity := PathValid(AbsPath);
if Validity = pvDirectory then
NewDir := AbsPath
else begin
NewDir := nil;
kfree(void(AbsPath));
end;
changeDirectoryFrom := Validity;
end;
{ Terminal Commands }
procedure VFS_COMMAND_PUSHD(params : PParamList; stdin_buf, stdout_buf, stderr_buf : POutBuf);
@@ -746,11 +811,8 @@ begin
//outputln('VFS', makeRelative('/test/mydisk/mything', '/test/mydisk'));
//while true do begin end;
{ Register Terminal Commands }
stdio.registerCommand('LS', @VFS_COMMAND_LS, 'List directory contents.');
stdio.registerCommand('CD', @VFS_COMMAND_CD, 'Set working directory.');
stdio.registerCommand('PUSHD', @VFS_COMMAND_PUSHD, 'Push the working directory.');
stdio.registerCommand('POPD', @VFS_COMMAND_POPD, 'Pop the working directory.');
{ LS, CD, PUSHD, POPD are now handled as per-terminal builtins
in vterminal.pas so each terminal has its own working directory. }
//ht:= PHashMap(Root^.Reference);
//hashmap.add(ht, 'VDirectory', void(newDummyObject(otVDIRECTORY)));