summaryrefslogtreecommitdiff
path: root/TRICKS
diff options
context:
space:
mode:
authorrsc <rsc>2007-11-28 20:47:22 +0000
committerrsc <rsc>2007-11-28 20:47:22 +0000
commitc2258bf4d249c34f26a4ed3c2d6ced81744c654e (patch)
treefefd4d60ed84be5307c1840226d2c95e093f77d4 /TRICKS
parent4f06ae0d4252796ee3245ecd83ec5ea105d6a75b (diff)
downloadxv6-labs-c2258bf4d249c34f26a4ed3c2d6ced81744c654e.tar.gz
xv6-labs-c2258bf4d249c34f26a4ed3c2d6ced81744c654e.tar.bz2
xv6-labs-c2258bf4d249c34f26a4ed3c2d6ced81744c654e.zip
fork minibug
Diffstat (limited to 'TRICKS')
-rw-r--r--TRICKS24
1 files changed, 24 insertions, 0 deletions
diff --git a/TRICKS b/TRICKS
index 6883588..b538834 100644
--- a/TRICKS
+++ b/TRICKS
@@ -110,3 +110,27 @@ moves reads down after writes, but the language in
the spec allows it. There is no telling whether future
processors will need it.
+---
+
+The code in sys_fork needs to read np->pid before
+setting np->state to RUNNABLE.
+
+ int
+ sys_fork(void)
+ {
+ int pid;
+ struct proc *np;
+
+ if((np = copyproc(cp)) == 0)
+ return -1;
+ pid = np->pid;
+ np->state = RUNNABLE;
+ return pid;
+ }
+
+After setting np->state to RUNNABLE, some other CPU
+might run the process, it might exit, and then it might
+get reused for a different process (with a new pid), all
+before the return statement. So it's not safe to just do
+"return np->pid;".
+