delay(9F)在使用中有种种限制,首先,它不能在interrupt context中调用。第一次的fix没有注意到这一点。被codereviewer指出来了。其次,它不能用于polled模式下,在polled模式下,“when system enters standalone mode, only one CPU and one thread keep active. Timesharing, interrupts and system services are turned off.” delay(9F)使用了timeout(9F),这是通过一个中断服务线程实现的。再次,在dev_ops的devo_reset 函数中也不能调用delay。因为devo_reset会被reset_leaves调到,即系统重启或关闭时,在文件86pc/os/machdep.c中可看到相关注释:
mdboot(int cmd, int fcn, char *mdep, boolean_t invoke_cb)
引用:/*
* stop other cpus and raise our priority. since there is only
* one active cpu after this, and our priority will be too high
* for us to be preempted, we're essentially single threaded
* from here on out.
*/
此时,系统处于单线程,单cpu状态, 与polled模式相同。
当以上这些都fix之后,在最后关头,再次被人质疑,delay不能用在mutex held情况下。因为在mutex_enter 的manpage中,有这么一个注意事项:
引用:Never hold a mutex when calling a service that may block,
for example kmem_alloc(9F) with KM_SLEEP or delay(9F).
Sigh!所以这个bug fix到目前为止还没有结束。
于 2013-08-14 17:16:26发表:
不错,谢谢,如果可以将你的问题和解决方法描述的再详细点对我们就更有帮助了。