]> git.corax.cc Git - corax/commitdiff
Protect processes with a spinlock
authorMatthias Kruk <m@m10k.eu>
Mon, 25 Nov 2019 05:43:17 +0000 (14:43 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 25 Nov 2019 05:43:17 +0000 (14:43 +0900)
kernel/core/process.c
kernel/include/process.h

index 784a7a5ab69cceb6cf321288c6d4e7d2c553ed2d..d1f223f6976822ca6d895946a7f80a2a6bff05bf 100644 (file)
@@ -8,6 +8,7 @@
 #include <process.h>
 #include <signal.h>
 #include <string.h>
+#include <spinlock.h>
 #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;
index b3a8a966eaacda6010e3f49ec15bae1444e623e1..ffbfc24e943bd4164b3572fde36a2cc678df1655 100644 (file)
@@ -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);