This commit is contained in:
2025-09-15 22:35:15 +02:00
parent ce63020b34
commit 0a5523f234
22 changed files with 374 additions and 177 deletions

View File

@ -29,7 +29,7 @@ int32_t SYSCALL5(sys_processctl, pid1, cmd1, arg1, arg2, arg3) {
if (proc == NULL) {
if (cmd == PCTL_POLLSTATE) {
ret = 2;
ret = PROC_DIED;
goto done;
}
ret = E_INVALIDARGUMENT;
@ -104,6 +104,44 @@ int32_t SYSCALL5(sys_processctl, pid1, cmd1, arg1, arg2, arg3) {
}
ret = E_OK;
} break;
case PCTL_PLS_SZ: {
size_t i = 0;
spinlock_acquire(&PROCS.spinlock);
Proc *p = PROCS.procs;
while (p) {
i++;
p = p->next;
}
spinlock_release(&PROCS.spinlock);
ret = i;
} break;
case PCTL_PLS_STAT: {
uint64_t pidx = arg1;
ProcStat *stat = (ProcStat *)arg2;
if (stat == NULL) {
ret = E_INVALIDARGUMENT;
goto done;
}
size_t i = 0;
spinlock_acquire(&PROCS.spinlock);
Proc *p = PROCS.procs;
while (p) {
if (i == pidx) {
stat->pid = p->pid;
hal_strcpy(stat->name, p->name);
stat->state = p->state;
stat->kern = p->kern;
break;
}
i++;
p = p->next;
}
spinlock_release(&PROCS.spinlock);
ret = E_OK;
} break;
default: {
ret = E_INVALIDARGUMENT;
} break;