summaryrefslogtreecommitdiffstats
path: root/sw/z80/kernel/process.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sw/z80/kernel/process.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sw/z80/kernel/process.c b/sw/z80/kernel/process.c
index 49b86b8..b43fa11 100644
--- a/sw/z80/kernel/process.c
+++ b/sw/z80/kernel/process.c
@@ -1,16 +1,32 @@
#include "process.h"
-struct process proc_table[255];
+static struct process proc_table[PID_COUNT_MAX];
+static struct process *current_proc;
pid_t newpid(void)
{
+ int i;
static pid_t last_pid = 0;
- return ++last_pid;
+
+ for (i = 0; i < PID_COUNT_MAX; i++, last_pid++) {
+ if (last_pid == PID_COUNT_MAX) {
+ last_pid = 0;
+ continue;
+ }
+
+ if (!proc_table[last_pid].running)
+ break;
+ }
+
+ if (i >= PID_COUNT_MAX)
+ return 0;
+
+ return last_pid;
}
int fork(void)
{
-
+
}
int exec(char *path, char *args)