Handle process arguments

This commit is contained in:
2025-09-10 23:25:03 +02:00
parent 2f9f4d9397
commit dc3d80d707
13 changed files with 127 additions and 23 deletions

View File

@ -198,7 +198,6 @@ Proc *proc_nextready(void) {
}
proc = proc->next;
}
return proc;
}
void proc_reaper(void) {
@ -243,6 +242,14 @@ void proc_reaper(void) {
}
pmm_free((uintptr_t)zombie->platformdata.cr3, 1);
ProcArg *arg = zombie->procargs.list;
while (arg) {
dlfree(arg->string);
ProcArg *tmp = arg;
arg = arg->next;
dlfree(tmp);
}
}
dlfree(zombie);
} else {
@ -251,19 +258,21 @@ void proc_reaper(void) {
}
}
extern void hal_zombiespin(void);
void proc_sched(void *cpustate) {
hal_intr_disable();
sched_ticks++;
if (sched_ticks % PROC_REAPER_FREQ == 0) {
proc_reaper();
}
IntrStackFrame *frame = cpustate;
PROCS.current->platformdata.trapframe = *frame;
PROCS.current = proc_nextready();
if (sched_ticks % PROC_REAPER_FREQ == 0) {
proc_reaper();
}
hal_switchproc(&PROCS.current->platformdata.trapframe, (void *)PROCS.current->platformdata.cr3);
}

View File

@ -7,6 +7,7 @@
#include "bitmap/bitmap.h"
#include "vfs/vfs.h"
#include "ipc/pipe/pipe.h"
#include "sysdefs/processctl.h"
#define PROC_NAME_MAX 0x100
@ -33,6 +34,11 @@ enum {
PROC_WAITING = 3,
};
typedef struct ProcArg {
struct ProcArg *next;
char string[PROC_ARG_MAX];
} ProcArg;
typedef struct Proc {
struct Proc *next;
@ -53,6 +59,10 @@ typedef struct Proc {
IpcPipe *list;
SpinLock spinlock;
} bcast_pipes;
struct {
ProcArg *list;
size_t len;
} procargs;
uint64_t mman_map_base;
} Proc;
@ -79,4 +89,12 @@ void proc_kill(Proc *proc);
for(;;); \
} while(0)
#define PROC_ARG(proc, str) \
do { \
ProcArg *__arg = dlmalloc(sizeof(*__arg)); \
hal_strcpy(__arg->string, (str)); \
LL_APPEND((proc)->procargs.list, __arg); \
(proc)->procargs.len++; \
} while(0)
#endif // PROC_PROC_H_