From 505138cc46f6e2c0fabe03e98206ad6877709185 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Mon, 25 Nov 2019 14:43:17 +0900 Subject: [PATCH] Protect processes with a spinlock --- kernel/core/process.c | 14 ++++++++++++++ kernel/include/process.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/kernel/core/process.c b/kernel/core/process.c index 784a7a5..d1f223f 100644 --- a/kernel/core/process.c +++ b/kernel/core/process.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "fd.h" #include "sched.h" @@ -26,6 +27,8 @@ struct process { uid_t p_uid; gid_t p_gid; + spinlock_t p_lock; + struct { struct cxmsg *msg; pid_t sender; @@ -439,6 +442,17 @@ int process_switch(process_t *proc) return(ret_val); } +void process_lock(process_t *proc) +{ + spinlock_lock(&(proc->p_lock)); + return; +} + +int process_unlock(process_t *proc) +{ + return(spinlock_unlock(&(proc->p_lock))); +} + process_t* process_get_current(void) { process_t *ret_val; diff --git a/kernel/include/process.h b/kernel/include/process.h index b3a8a96..ffbfc24 100644 --- a/kernel/include/process.h +++ b/kernel/include/process.h @@ -31,6 +31,9 @@ typedef struct process process_t; int process_create(process_t**, pid_t, u32_t, void*); int process_switch(process_t*); +void process_lock(process_t*); +int process_unlock(process_t*); + process_t* process_get_current(void); process_t* process_lookup(pid_t); -- 2.47.3