Compare commits
1 Commits
userprog-s
...
rox-check-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
987a71ec40 |
@@ -212,7 +212,6 @@ donate_priority (struct thread *donee) {
|
||||
ASSERT (intr_get_level () == INTR_OFF);
|
||||
|
||||
struct thread *donor = thread_current ();
|
||||
list_remove (&donor->donor_elem);
|
||||
list_push_back (&donee->donors_list, &donor->donor_elem);
|
||||
|
||||
while (donee != NULL)
|
||||
@@ -261,7 +260,6 @@ lock_acquire (struct lock *lock)
|
||||
ASSERT (!lock_held_by_current_thread (lock));
|
||||
|
||||
struct thread *t = thread_current ();
|
||||
ASSERT (t->waiting_lock == NULL);
|
||||
|
||||
enum intr_level old_level = intr_disable ();
|
||||
if (lock->holder != NULL)
|
||||
@@ -343,6 +341,7 @@ lock_release (struct lock *lock)
|
||||
released, transfer the remaining orphaned donors to its donor list. */
|
||||
if (max_donor != NULL)
|
||||
{
|
||||
list_remove (&max_donor->donor_elem);
|
||||
while (!list_empty (&orphan_list))
|
||||
list_push_back (&max_donor->donors_list, list_pop_front (&orphan_list));
|
||||
}
|
||||
|
||||
@@ -373,9 +373,7 @@ thread_exit (void)
|
||||
and schedule another process. That process will destroy us
|
||||
when it calls thread_schedule_tail(). */
|
||||
intr_disable ();
|
||||
struct thread *t = thread_current ();
|
||||
list_remove (&t->allelem);
|
||||
list_remove (&t->donor_elem);
|
||||
list_remove (&thread_current()->allelem);
|
||||
thread_current ()->status = THREAD_DYING;
|
||||
schedule ();
|
||||
NOT_REACHED ();
|
||||
@@ -681,7 +679,6 @@ init_thread (struct thread *t, const char *name, int nice, int priority,
|
||||
t->base_priority
|
||||
= thread_mlfqs ? calculate_bsd_priority (recent_cpu, nice) : priority;
|
||||
list_init (&t->donors_list);
|
||||
list_push_back (&t->donors_list, &t->donor_elem);
|
||||
t->waiting_lock = NULL;
|
||||
|
||||
t->nice = nice;
|
||||
|
||||
@@ -82,14 +82,8 @@ process_execute (const char *cmd)
|
||||
of the process. */
|
||||
char *file_name = strtok_r (cmd_copy, " ", &data->cmd_saveptr);
|
||||
|
||||
/* NOTE: Currently, the file being executed is closed in load () and then
|
||||
reopened here. Because load is an exported public function, this
|
||||
might be necessary. */
|
||||
lock_acquire (&filesys_lock);
|
||||
/* Validates that the current file to be executed is a valid file */
|
||||
bool valid_file = filesys_open (file_name) != NULL;
|
||||
lock_release (&filesys_lock);
|
||||
if (!valid_file)
|
||||
if (filesys_open (file_name) == NULL)
|
||||
return TID_ERROR;
|
||||
|
||||
/* Create a new thread to execute the command, by initializing
|
||||
@@ -127,15 +121,6 @@ start_process (void *proc_start_data)
|
||||
if_.gs = if_.fs = if_.es = if_.ds = if_.ss = SEL_UDSEG;
|
||||
if_.cs = SEL_UCSEG;
|
||||
if_.eflags = FLAG_IF | FLAG_MBS;
|
||||
|
||||
lock_acquire (&filesys_lock);
|
||||
|
||||
/* 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);
|
||||
lock_release (&filesys_lock);
|
||||
|
||||
success = load (data->file_name, &if_.eip, &if_.esp);
|
||||
|
||||
/* If load failed, quit. */
|
||||
@@ -157,6 +142,13 @@ start_process (void *proc_start_data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* NOTE: Currently, the file being executed is closed in load () and then
|
||||
reopened here. Because load is an exported public function, this
|
||||
might be necessary. */
|
||||
struct file *exec_file = filesys_open (data->file_name);
|
||||
thread_current ()->exec_file = exec_file;
|
||||
file_deny_write (exec_file);
|
||||
|
||||
/* Start the user process by simulating a return from an
|
||||
interrupt, implemented by intr_exit (in
|
||||
threads/intr-stubs.S). Because intr_exit takes all of its
|
||||
@@ -325,13 +317,7 @@ process_exit (void)
|
||||
uint32_t *pd;
|
||||
|
||||
printf ("%s: exit(%d)\n", cur->name, cur->exit_status);
|
||||
if (cur->exec_file != NULL)
|
||||
{
|
||||
lock_acquire (&filesys_lock);
|
||||
file_allow_write (cur->exec_file);
|
||||
file_close (cur->exec_file);
|
||||
lock_release (&filesys_lock);
|
||||
}
|
||||
file_close (cur->exec_file);
|
||||
|
||||
/* Update process result. */
|
||||
if (cur->result != NULL)
|
||||
@@ -491,7 +477,6 @@ 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 ();
|
||||
@@ -591,7 +576,6 @@ 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