local_intr_save(intr_flag);
{
current = proc;
load_esp0(next->kstack + KSTACKSIZE);
lcr3(next->cr3);
switch_to(&(prev->context), &(next->context));
}
local_intr_restore(intr_flag);
这是proc_run中的一段。
有2个疑问:
①在进行switch_to操作时,ret时,已经将运行环境的8个寄存器从from进程的换成了to进程的,因此在ret后直接跳转到forkret,进而iret到kernel_thread_entry处开始运行main,那么上述代码中的最后一行将迟迟不能执行,也就是说中断被关闭后迟迟不能开启,导致中断堵塞,直到main进程执行do_exit操作。这是合理的吗?或者是我理解错了?
②local_intr_save(intr_flag)是一个宏,其内容为
#define local_intr_save(x) do { x = __intr_save(); } while (0)
为什么要采用while(0)这种奇怪的写法?