diff options
| author | Robert Morris <rtm@csail.mit.edu> | 2014-08-04 06:13:49 -0400 |
|---|---|---|
| committer | Robert Morris <rtm@csail.mit.edu> | 2014-08-04 06:13:49 -0400 |
| commit | 020c8e2384877ffc13579f633ac3c723f80baf8c (patch) | |
| tree | bcc593b814cfc416c6ba08d386bd6d269c7fa157 /proc.c | |
| parent | 86188d9d49fe62a2f4d8b0677d33608b3b949336 (diff) | |
| download | xv6-labs-2022-020c8e2384877ffc13579f633ac3c723f80baf8c.tar.xz xv6-labs-2022-020c8e2384877ffc13579f633ac3c723f80baf8c.zip | |
use acquire/release to force order for pid=np->pid;np->state=RUNNING
for bug reported by symingz@gmail.com and cs1100254@cse.iitd.ernet.in
Diffstat (limited to 'proc.c')
| -rw-r--r-- | proc.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -153,10 +153,16 @@ fork(void) if(proc->ofile[i]) np->ofile[i] = filedup(proc->ofile[i]); np->cwd = idup(proc->cwd); + + safestrcpy(np->name, proc->name, sizeof(proc->name)); pid = np->pid; + + // lock to force the compiler to emit the np->state write last. + acquire(&ptable.lock); np->state = RUNNABLE; - safestrcpy(np->name, proc->name, sizeof(proc->name)); + release(&ptable.lock); + return pid; } @@ -455,5 +461,3 @@ procdump(void) cprintf("\n"); } } - - |
