【问题标题】:What check to make in exec-missing in PINTOS在 PINTOS 的 exec-missing 中进行什么检查
【发布时间】:2015-12-10 15:41:13
【问题描述】:

我正在从事 Pintos Project #2。我已经实现了大部分系统调用。在 exec 系统调用中,有一个测试 exec-missing 根据文件中的注释检查:

    /* Tries to execute a nonexistent process.
   The exec system call must return -1. */

#include <syscall.h>
#include "tests/lib.h"
#include "tests/main.h"

void
test_main (void) 
{
  msg ("exec(\"no-such-file\"): %d", exec ("no-such-file"));
}

我不知道如何在我的执行代码中检查这一点。我已经正确检查了帧指针,可能缺少什么?

【问题讨论】:

    标签: operating-system pintos


    【解决方案1】:

    指定为“exec”的第一个参数的可执行文件是从start_process() 函数中的load() 函数加载的。

    提醒您,start_process() 是作为新创建进程的一部分运行的函数。该函数负责将可执行文件加载到内存中并开始执行。

    如果找不到可执行文件,那么load()函数会返回0报错。在此之后,您需要释放分配给进程的所有内存,并通过调用exit() 系统调用或调用process_exit() 函数来结束它。

    可以先调试load()函数的返回状态。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-06
      • 2019-09-24
      • 2022-12-05
      • 1970-01-01
      • 1970-01-01
      • 2020-08-13
      • 2015-04-14
      相关资源
      最近更新 更多