Browse Source

i don't crash instantly anymore!

tarfeef101 6 years ago
parent
commit
800751896b

BIN
build/install/hostbin/host-dumpsfs


BIN
build/install/hostbin/host-hash


BIN
build/install/hostbin/host-mksfs


BIN
build/install/hostbin/host-sfsck


BIN
build/user/sbin/dumpsfs/dumpsfs.ho


BIN
build/user/sbin/dumpsfs/host-dumpsfs


BIN
build/user/sbin/mksfs/host-mksfs


BIN
build/user/sbin/mksfs/mksfs.ho


BIN
build/user/sbin/sfsck/host-sfsck


BIN
build/user/sbin/sfsck/sfsck.ho


BIN
build/user/testbin/hash/hash.ho


BIN
build/user/testbin/hash/host-hash


+ 6 - 2
kern/arch/mips/syscall/syscall.c

@@ -130,6 +130,9 @@ syscall(struct trapframe * tf)
 			    (int)tf->tf_a2,
 			    (pid_t *)&retval);
 	  break;
+	case SYS_fork:
+	  err = sys_fork(tf, (pid_t*)&retval);
+	  break;
 #endif // UW
 
 	    /* Add stuff here */
@@ -179,12 +182,13 @@ syscall(struct trapframe * tf)
  *
  * Thus, you can trash it and do things another way if you prefer.
  */
-void enter_forked_process(void * trap)
+void enter_forked_process(void * trap, unsigned long x)
 {
+  (void)x;
 	struct trapframe * tf = (struct trapframe *)trap;
 	struct trapframe childframe = *tf;
 	childframe.tf_v0 = 0;
 	childframe.tf_epc += 4;
 	childframe.tf_a3 = 0;
-	mips_usermode(&childTf);
+	mips_usermode(&childframe);
 }

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

+ 1 - 1
kern/compile/ASST2/version

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

+ 1 - 1
kern/include/proc.h

@@ -81,7 +81,7 @@ struct proc
 // struct that contains all the processes in the system
 struct procs
 {
-  struct proc * pids[PID_MAX - PID_MIN + 1]; // total # of valid PIDs
+  struct proc  * pids[PID_MAX - PID_MIN + 1]; // total # of valid PIDs
   int lastpid; // last pid issued
 };
 

+ 1 - 1
kern/include/syscall.h

@@ -44,7 +44,7 @@ void syscall(struct trapframe * tf);
  */
 
 /* Helper for fork(). You write this. */
-void enter_forked_process(struct trapframe * tf);
+void enter_forked_process(void * trap, unsigned long x);
 
 /* Enter user mode. Does not return. */
 void enter_new_process(int argc, userptr_t argv, vaddr_t stackptr,

+ 11 - 5
kern/proc/proc.c

@@ -129,13 +129,13 @@ static struct proc * proc_create(const char * name)
 	return proc;
 }
 
-/*static procs * create_procs(void)
+static procs * create_procs(void)
 {
-  procs * temp = kmalloc(sizeof procs);
+  procs * temp = kmalloc(sizeof(procs));
   if (!(temp)) panic("Could not create process list!\n");
   temp->lastpid = PID_MIN - 1;
   return temp;
-}*/
+}
 
 struct proc * getChild(struct proc * p, int pid)
 {
@@ -155,6 +155,7 @@ int assignpid(struct proc * proc)
     {
       proc->pid = i;
       processes->lastpid = i;
+      processes->pids[i] = proc;
       lock_release(proclock);
       return i;
     }
@@ -172,6 +173,7 @@ int assignpid(struct proc * proc)
     }
   }
   
+  lock_release(proclock);
   return ENPROC;
 }
 
@@ -245,7 +247,7 @@ void proc_destroy(struct proc * proc)
 	spinlock_cleanup(&proc->p_lock);
 
   lock_acquire(proclock);
-  processes->pids[proc->pid] = 0; // update available PIDs
+  processes->pids[proc->pid] = NULL; // update available PIDs
   lock_release(proclock);
 	kfree(proc->p_name);
 	kfree(proc);
@@ -294,11 +296,15 @@ void proc_bootstrap(void)
   }
 #endif // UW
   
+  processes = create_procs();
   int processesLen = PID_MAX - PID_MIN + 1;
   for (int i = 0; i < processesLen; i++)
   {
-    processes->pids[i] = 0;
+    processes->pids[i] = NULL;
   }
+
+  proclock = lock_create("proclock");
+  if (!(proclock)) panic("Process manager lock could not be created!\n");
 }
 
 /*

+ 2 - 2
kern/syscall/proc_syscalls.c

@@ -41,7 +41,7 @@ void sys__exit(int exitcode)
   /* detach this thread from its process */
   /* note: curproc cannot be used after this call */
   proc_remthread(curthread);
-
+
   /* if this is the last user process in the system, proc_destroy()
      will wake up the kernel menu thread */
   proc_destroy(p);
@@ -113,7 +113,7 @@ int sys_fork(struct trapframe * tf, int * retval)
   child->parent = curproc;
   *new_tf = *tf;
   
-  // start new thread
+    // start new thread
   thread_fork("childproc", child, enter_forked_process, new_tf, 0);
   
   // return correct values