reading process acquired p->lock and released virtio lock in sleep(), but before the process had set p->status to SLEEPING, because the wakeup tested p->status without holding p's lock. Thus, wakeup can complete without seeing any process SLEEPING and then p sets p->status to SLEEPING. Fix some other issues: - Don't initialize proc lock in allocproc(), because freeproc() sets np->state = UNUSED and allocproc() can choose np and calls initlock() on the process's lock, releasing np's lock accidentally. Move initializing proc's lock to init. - Protect nextpid using ptable.lock (and move into its own function) Some clean up: - Don't acquire p->lock when it p is used in a private way (e.g., exit()/grow()). - Move find_runnable() back into scheduler(). |
||
|---|---|---|
| .. | ||
| bio.c | ||
| buf.h | ||
| console.c | ||
| date.h | ||
| defs.h | ||
| elf.h | ||
| entry.S | ||
| exec.c | ||
| fcntl.h | ||
| file.c | ||
| file.h | ||
| fs.c | ||
| fs.h | ||
| kalloc.c | ||
| kernel.ld | ||
| kernelvec.S | ||
| log.c | ||
| main.c | ||
| memlayout.h | ||
| param.h | ||
| pipe.c | ||
| plic.c | ||
| proc.c | ||
| proc.h | ||
| ramdisk.c | ||
| riscv.h | ||
| sleeplock.c | ||
| sleeplock.h | ||
| spinlock.c | ||
| spinlock.h | ||
| start.c | ||
| stat.h | ||
| string.c | ||
| swtch.S | ||
| syscall.c | ||
| syscall.h | ||
| sysfile.c | ||
| sysproc.c | ||
| trampoline.S | ||
| trap.c | ||
| types.h | ||
| uart.c | ||
| virtio.h | ||
| virtio_disk.c | ||
| vm.c | ||