Browse Source

no longer leak memory, processes should actually have a list of children now

tarfeef101 6 years ago
parent
commit
a539b02dd1

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 = 13;
+const int buildversion = 16;
 const char buildconfig[] = "ASST2";

+ 1 - 1
kern/compile/ASST2/version

@@ -1 +1 @@
-13
+16

+ 2 - 0
kern/include/proc.h

@@ -126,5 +126,7 @@ int assignpid(struct proc * proc);
 // returns the child process if it is a child, otherwise null
 struct proc * getChild(struct proc * p, int pid);
 
+// adds child pid to parent's list
+void add_child(struct proc * parent, int pid);
 
 #endif /* _PROC_H_ */

+ 7 - 2
kern/proc/proc.c

@@ -124,8 +124,7 @@ static struct proc * proc_create(const char * name)
   // My additions
   proc->pid =0;
   proc->parent = NULL;
-  proc->kids = NULL;
-  
+
 	return proc;
 }
 
@@ -177,6 +176,11 @@ int assignpid(struct proc * proc)
   return ENPROC;
 }
 
+void add_child(struct proc * parent, int pid)
+{
+  listsert(parent->kids, pid);
+}
+
 /*
 static void delete_procs()
 {
@@ -249,6 +253,7 @@ void proc_destroy(struct proc * proc)
   lock_acquire(proclock);
   processes->pids[proc->pid] = NULL; // update available PIDs
   lock_release(proclock);
+  listelete(proc->kids);
 	kfree(proc->p_name);
 	kfree(proc);
 

+ 1 - 0
kern/syscall/proc_syscalls.c

@@ -111,6 +111,7 @@ int sys_fork(struct trapframe * tf, int * retval)
   // set PIDs, etc. copy data in to the new space
   child->p_addrspace = new_as;
   child->parent = curproc;
+  add_child(curproc, child->pid);
   *new_tf = *tf;
   
     // start new thread