

A file may be removed regardless of whether it is open or closed, and removing an open file does not close it. Returns true if successful, false otherwise. System Call: bool remove (const char *file)ĭeletes the file called file.Creating a new file does not open it: opening the new file is a separate operation which would require a open system call. System Call: bool create (const char *file, unsigned initial_size)Ĭreates a new file called file initially initial_size bytes in size.Implementing this system call requires considerably more work than any of the rest. We suggest that you implement process_wait() according to the comment at the top of the function and then implement the wait system call in terms of process_wait().
PINTOS PROJECT2 ARGUMENT PASSING CODE
The supplied Pintos code tries to do this by calling process_wait() (in userprog/process.c) from main() (in threads/init.c). You must ensure that Pintos does not terminate until the initial process exits. All of a process's resources, including its struct thread, must be freed whether its parent ever waits for it or not, and regardless of whether the child exits before or after its parent.

Your design should consider all the ways in which waits can occur. Processes may spawn any number of children, wait for them in any order, and may even exit without having waited for some or all of their children. That is, a process may wait for any given child at most once. The process that calls wait has already called wait on pid. Similarly, orphaned processes are not assigned to a new parent if their parent process exits before they do. A call to wait(C) by process A must fail. Note that children are not inherited: if A spawns child B and B spawns child process C, then A cannot wait for C, even if B is dead. pid is a direct child of the calling process if and only if the calling process received pid as a return value from a successful call to exec. Pid does not refer to a direct child of the calling process. Wait must fail and return -1 immediately if any of the following conditions is true: It is perfectly legal for a parent process to wait for child processes that have already terminated by the time the parent calls wait, but the kernel must still allow the parent to retrieve its child's exit status, or learn that the child was terminated by the kernel. killed due to an exception), wait(pid) must return -1. If pid did not call exit(), but was terminated by the kernel (e.g. Then, returns the status that pid passed to exit. If pid is still alive, waits until it terminates. Waits for a child process pid and retrieves the child's exit status.

You must use appropriate synchronization to ensure this. Thus, the parent process cannot return from the exec until it knows whether the child process successfully loaded its executable. Must return pid -1, which otherwise should not be a valid pid, if the program cannot load or run for any reason. Runs the executable whose name is given in cmd_line, passing any given arguments, and returns the new process's program id (pid). System Call: pid_t exec (const char *cmd_line).Conventionally, a status of 0 indicates success and nonzero values indicate errors. If the process's parent waits for it (see below), this is the status that will be returned. Terminates the current user program, returning status to the kernel. This should be seldom used, because you lose some information about possible deadlock situations, etc. Terminates Pintos by calling shutdown_power_off() (declared in threads/init.h). (This header, and all others in lib/user, are for use by user programs only.) System call numbers for each system call are defined in lib/syscall-nr.h: The prototypes listed are those seen by a user program that includes lib/user/syscall.h. It will need to retrieve the system call number, then any system call arguments, and carry out appropriate actions. The skeleton implementation we provide "handles" system calls by terminating the process.

Implement the system call handler in userprog/syscall.c.
