Fix syn-read, syn-write, and always free elements from donors_list
This commit is contained in:
@@ -133,11 +133,10 @@ start_process (void *proc_start_data)
|
||||
/* Prevent writing to the file being executed. */
|
||||
struct file *exec_file = filesys_open (data->file_name);
|
||||
thread_current ()->exec_file = exec_file;
|
||||
file_deny_write(exec_file);
|
||||
file_deny_write (exec_file);
|
||||
lock_release (&filesys_lock);
|
||||
|
||||
success = load (data->file_name, &if_.eip, &if_.esp);
|
||||
|
||||
lock_release (&filesys_lock);
|
||||
|
||||
/* If load failed, quit. */
|
||||
if (!success)
|
||||
@@ -326,7 +325,13 @@ process_exit (void)
|
||||
uint32_t *pd;
|
||||
|
||||
printf ("%s: exit(%d)\n", cur->name, cur->exit_status);
|
||||
file_close (cur->exec_file);
|
||||
if (cur->exec_file != NULL)
|
||||
{
|
||||
lock_acquire (&filesys_lock);
|
||||
file_allow_write (cur->exec_file);
|
||||
file_close (cur->exec_file);
|
||||
lock_release (&filesys_lock);
|
||||
}
|
||||
|
||||
/* Update process result. */
|
||||
if (cur->result != NULL)
|
||||
@@ -486,6 +491,7 @@ load (const char *file_name, void (**eip) (void), void **esp)
|
||||
off_t file_ofs;
|
||||
bool success = false;
|
||||
int i;
|
||||
lock_acquire (&filesys_lock);
|
||||
|
||||
/* Allocate and activate page directory. */
|
||||
t->pagedir = pagedir_create ();
|
||||
@@ -585,6 +591,7 @@ load (const char *file_name, void (**eip) (void), void **esp)
|
||||
done:
|
||||
/* We arrive here whether the load is successful or not. */
|
||||
file_close (file);
|
||||
lock_release (&filesys_lock);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user