summaryrefslogtreecommitdiffstats
path: root/sw-old/z80/kernel/process.c
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-10-30 11:41:24 +0100
committerNao Pross <naopross@thearcway.org>2018-10-30 11:41:24 +0100
commit43be150dc6e84f6f6eeb071cd3cdb7fc21125d60 (patch)
tree541fd3d690c1bdfd7b68d684029a400b80f4aa06 /sw-old/z80/kernel/process.c
parentAdd datasheets for ATmega328 and 74LS259 (diff)
downloadz80uPC-43be150dc6e84f6f6eeb071cd3cdb7fc21125d60.tar.gz
z80uPC-43be150dc6e84f6f6eeb071cd3cdb7fc21125d60.zip
Move sw to sw-old and hw to hw-altium, add kicad files
Diffstat (limited to 'sw-old/z80/kernel/process.c')
-rw-r--r--sw-old/z80/kernel/process.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/sw-old/z80/kernel/process.c b/sw-old/z80/kernel/process.c
new file mode 100644
index 0000000..7d8db89
--- /dev/null
+++ b/sw-old/z80/kernel/process.c
@@ -0,0 +1,58 @@
+#include "process.h"
+
+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;
+
+ 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 i, p;
+ pid_t child_pid = newpid();
+
+ if (child_pid == 0)
+ return -1;
+
+
+ for (i = 0; i < current_proc->pages; i++) {
+ p = page_new();
+
+ if (p == -1) {
+ return -2;
+ }
+
+ // TODO: use memcpy()
+ // SDCC does not allow assignemnts of structs
+
+ // proc_table[child_pid].page[i] = p;
+ }
+}
+
+int exec(char *path, char *args)
+{
+
+}
+
+int spawn(char *path, char *args)
+{
+
+}