operating-systempintos

What check to make in exec-missing in PINTOS


I am working on Pintos Project # 2. I have implemented most of the system calls. In exec system call, there is a test exec-missing which according to comment in file checks this:

    /* 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"));
}

I cant figure our how to check this in my exec code. I have put a check on the frame pointer correctly, what could be missing ?


Solution

  • The executable file specified as the first argument for "exec" is loaded from the load() function present in the start_process() function.

    To remind you, start_process() is where function which is run as part of the newly created process. This function is responsible for loading the executable onto the memory and start executing it.

    If the executable file is not found, then the load() function will report an error by returning 0. After this, you need to deallocate all the memory which was allocated for the process and end it by calling the exit() system call or by calling the process_exit() function.

    You can start by debugging the return status of the load() function.