Fix minor kthread bug
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 5 Feb 2014 06:33:37 +0000 (22:33 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Sun, 9 Feb 2014 07:22:59 +0000 (23:22 -0800)
If you block during initialization, you'll catch this.

kern/src/kthread.c

index a6b8889..df0e703 100644 (file)
@@ -329,7 +329,8 @@ void sem_down(struct semaphore *sem)
         * the process context and transfer the refcnt to kthread->proc. */
        if (!kthread->is_ktask) {
                kthread->proc = current;
-               proc_incref(kthread->proc, 1);
+               if (kthread->proc)      /* still could be none, like during init */
+                       proc_incref(kthread->proc, 1);
        } else {
                kthread->proc = 0;
        }