summaryrefslogtreecommitdiff
path: root/kernel/proc.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-09-23 07:24:41 -0400
committerRobert Morris <[email protected]>2019-09-23 07:24:41 -0400
commit37df68e5dedbf2a26c2bf0bdae090b206ce78b48 (patch)
tree6234b10e5fb5b1888cc5caa28dd85e8b6f0c3df9 /kernel/proc.c
parentd175beadf5f009d0fb8881e32c913b1bc175c9f6 (diff)
downloadxv6-labs-37df68e5dedbf2a26c2bf0bdae090b206ce78b48.tar.gz
xv6-labs-37df68e5dedbf2a26c2bf0bdae090b206ce78b48.tar.bz2
xv6-labs-37df68e5dedbf2a26c2bf0bdae090b206ce78b48.zip
story is more complex than I thought.
Diffstat (limited to 'kernel/proc.c')
-rw-r--r--kernel/proc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/kernel/proc.c b/kernel/proc.c
index 4f6caee..bbf3af0 100644
--- a/kernel/proc.c
+++ b/kernel/proc.c
@@ -336,18 +336,21 @@ exit(int status)
end_op();
p->cwd = 0;
- // we might re-parent a child to init. we can't be precise
- // about waking up init, since we can't acquire its lock once
- // we've acquired any other proc lock. so wake up init whether
- // that's necessary or not. init may miss this wakeup,
- // that that seems harmless.
+ // we might re-parent a child to init. we can't be precise about
+ // waking up init, since we can't acquire its lock once we've
+ // acquired any other proc lock. so wake up init whether that's
+ // necessary or not. init may miss this wakeup, but that seems
+ // harmless.
acquire(&initproc->lock);
wakeup1(initproc);
release(&initproc->lock);
- // grab a copy of p->parent, to ensure that we unlock the
- // same parent we locked. in case our parent gives us away
- // to init while we're waiting for the parent lock.
+ // grab a copy of p->parent, to ensure that we unlock the same
+ // parent we locked. in case our parent gives us away to init while
+ // we're waiting for the parent lock. we may then race with an
+ // exiting parent, but the result will be a harmless spurious wakeup
+ // to a dead or wrong process; proc structs are never re-allocated
+ // as anything else.
acquire(&p->lock);
struct proc *original_parent = p->parent;
release(&p->lock);