Update process_execute to acquire lock when checking if file exists

This commit is contained in:
Themis Demetriades
2024-11-12 16:12:24 +00:00
parent 3418425f20
commit b0400693ae

View File

@@ -85,12 +85,11 @@ process_execute (const char *cmd)
/* NOTE: Currently, the file being executed is closed in load () and then /* NOTE: Currently, the file being executed is closed in load () and then
reopened here. Because load is an exported public function, this reopened here. Because load is an exported public function, this
might be necessary. */ might be necessary. */
struct file *exec_file = filesys_open (file_name); lock_acquire (&filesys_lock);
file_deny_write (exec_file); /* Validates that the current file to be executed is a valid file */
if (filesys_open (file_name) == NULL)
/* Validates that the current file to be executed is a valid file */ return TID_ERROR;
if (filesys_open (file_name) == NULL) lock_release (&filesys_lock);
return TID_ERROR;
/* Create a new thread to execute the command, by initializing /* Create a new thread to execute the command, by initializing
it running the function 'start_process' with the appropriate it running the function 'start_process' with the appropriate