如何在进程结束后自动关闭`qemu`的执行?

Alf*_*ran 6 linux operating-system qemu pintos

我希望qemu打开并显示输出后的窗口在运行后自动关闭pintOS

就像我pintos -- run alarm-multipletcshshell中运行命令一样,qemu显示该进程开始,然后一些alarm-notifications然后进程结束,但之后qemu窗口将不会关闭

我想在成功完成系统调用后退出窗口.

yak*_*out 5

更新:


新的解决方案

这里是另一个更好的解决方案,将两个工作pintos run ...make grade

将此行添加到devices/shutdown.c :: shutdown_power_off(void)在循环之前。

outw( 0x604, 0x0 | 0x2000 ); 
Run Code Online (Sandbox Code Playgroud)

旧的解决方案

对于较新版本的 qemu,您需要使用选项运行它

-device isa-debug-exit
Run Code Online (Sandbox Code Playgroud)

在对 IO 端口的任何写入时退出,默认情况下它是 0x501

src/utils目录下的pintos项目中,您需要在run_qemu子例程中的pintos文件中添加一行

sub run_qemu {
    print "warning: qemu doesn't support --terminal\n"
       if $vga eq 'terminal';
    print "warning: qemu doesn't support jitter\n"
       if defined $jitter;
    my (@cmd) = ('qemu-system-i386');

    push (@cmd, '-device', 'isa-debug-exit'); # <====== add this line
    ..
    ..
    push (@cmd, '-monitor', 'null') if $vga eq 'none' && $debug eq 'none';
    run_command (@cmd);
}
Run Code Online (Sandbox Code Playgroud)

并在devices目录下的shutdown.c文件中,在for循环后的shutdown_power_off函数中添加这一行

for (p = s; *p != '\0'; p++)
    outb (0x8900, *p);

outb (0x501, 0x31); // <====== add this line
Run Code Online (Sandbox Code Playgroud)

Qemu 的退出代码是值的两倍加一,所以没有办法干净地退出。使用 0x31 这应该会导致 0x63 的 qemu 退出代码

最后使用 -q 选项运行 pintos

pintos -q run alarm-multiple
Run Code Online (Sandbox Code Playgroud)
  • 注意:此解决方案不起作用,make grade请参阅@pranav3688 下面的评论以获取解决方案。