summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
authordzwdz2021-07-26 18:17:01 +0200
committerdzwdz2021-07-26 18:17:01 +0200
commit2ae4e31b74efa29cc92554647d5c9dce077971c4 (patch)
treecb87d1979ead008b49839ba52245960d81669db5 /src/kernel/proc.c
parentbfe381768bf9fde9595a7fdacfb8037458fc0f6a (diff)
fork() pt 1: cloning process memory
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r--src/kernel/proc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 9c7e390..b165878 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -1,6 +1,7 @@
#include <kernel/arch/generic.h>
#include <kernel/mem.h>
#include <kernel/proc.h>
+#include <kernel/util.h>
#include <stdint.h>
struct process *process_current;
@@ -23,6 +24,14 @@ struct process *process_new() {
return proc;
}
+struct process *process_clone(const struct process *orig) {
+ struct process *clone = page_alloc(1);
+ memcpy(clone, orig, sizeof(struct process));
+ clone->pages = pagedir_copy(orig->pages);
+
+ return clone;
+}
+
void process_switch(struct process *proc) {
process_current = proc;
pagedir_switch(proc->pages);