First, I'm not sure whether my discovery is correct.
Suppose such follow scene: We call sleep() at kernel/virtio_disk.c:285, and then the spinlock disk.vdisk_lock will be released at kernel/proc.c:548 but without modifying the state of p->chan and p->state correctly; Unfortunately another hart has received virto_disk's interrupt request and executes to kernel/virtio_disk.c:321 at the same time, then this interrupt processing couldn't find a process that meet the conditions if(p->state == SLEEPING && p->chan == chan) { at kernel/proc.c:574. The wakeup() function does nothing! And the worse is, when line 551 and 552 in kernel/proc.c done after wakeup()'s traversal, the state of own process who invoked virto_disk_rw() will be SLEEPING forever!
First, I'm not sure whether my discovery is correct. Suppose such follow scene: We call
sleep()
atkernel/virtio_disk.c:285
, and then the spinlockdisk.vdisk_lock
will be released atkernel/proc.c:548
but without modifying the state ofp->chan
andp->state
correctly; Unfortunately another hart has received virto_disk's interrupt request and executes tokernel/virtio_disk.c:321
at the same time, then this interrupt processing couldn't find a process that meet the conditionsif(p->state == SLEEPING && p->chan == chan) {
atkernel/proc.c:574
. Thewakeup()
function does nothing! And the worse is, when line 551 and 552 inkernel/proc.c
done afterwakeup()
's traversal, the state of own process who invokedvirto_disk_rw()
will be SLEEPING forever!