Browse Source

using proclock more

tarfeef101 6 years ago
parent
commit
42307f5601

BIN
kern/compile/ASST2/kernel


+ 1 - 1
kern/compile/ASST2/vers.c

@@ -1,3 +1,3 @@
 /* This file is automatically generated. Edits will be lost.*/
-const int buildversion = 67;
+const int buildversion = 71;
 const char buildconfig[] = "ASST2";

+ 1 - 1
kern/compile/ASST2/version

@@ -1 +1 @@
-67
+71

+ 2 - 0
kern/proc/proc.c

@@ -141,7 +141,9 @@ static procs * create_procs(void)
 
 struct proc * getChild(struct proc * p, int pid)
 {
+  lock_acquire(proclock);
   int result = listearch(p->kids, pid);
+  lock_release(proclock);
 
   if (!(result)) return NULL;
   return processes->pids[pid];

+ 4 - 1
kern/syscall/proc_syscalls.c

@@ -119,7 +119,9 @@ void sys__exit(int exitcode)
   int x = listpop(p->kids);
   while (x)
   {
+    lock_acquire(proclock);
     processes->pids[x]->parent = NULL;
+    lock_release(proclock);
     x = listpop(p->kids);
   }
   
@@ -137,10 +139,11 @@ void sys__exit(int exitcode)
     proc_destroy(p);
   }
   
+  kprintf("curproc is: %p", curproc);
   /* if this is the last user process in the system, proc_destroy()
      will wake up the kernel menu thread */
   //proc_destroy(p);
-  if (!(curproc)) thread_exit();
+  thread_exit();
   /* thread_exit() does not return, so we should never get here */
   panic("return from thread_exit in sys_exit\n");
 }