Update releasing of locks to update donation information w/ S
This commit is contained in:
@@ -265,6 +265,18 @@ lock_release (struct lock *lock)
|
||||
ASSERT (lock != NULL);
|
||||
ASSERT (lock_held_by_current_thread (lock));
|
||||
|
||||
struct thread *current_thread = thread_current ();
|
||||
struct list_elem *tail = list_tail (¤t_thread->donors_list);
|
||||
for (struct list_elem *e = list_begin (¤t_thread->donors_list);
|
||||
e != tail; e = e->next)
|
||||
{
|
||||
struct thread *donor = list_entry (e, struct thread, donor_elem);
|
||||
if (donor->waiting_lock == lock)
|
||||
list_remove (e);
|
||||
}
|
||||
|
||||
thread_recalculate_priority ();
|
||||
|
||||
lock->holder = NULL;
|
||||
sema_up (&lock->semaphore);
|
||||
}
|
||||
|
||||
@@ -408,6 +408,13 @@ thread_get_priority (void)
|
||||
return thread_current ()->priority;
|
||||
}
|
||||
|
||||
/* Recalculates the effective priority of the current thread. */
|
||||
void
|
||||
thread_recalculate_priority (void)
|
||||
{
|
||||
barrier ();
|
||||
};
|
||||
|
||||
/* Sets the current thread's nice value to NICE. */
|
||||
void
|
||||
thread_set_nice (int nice UNUSED)
|
||||
|
||||
@@ -144,6 +144,7 @@ bool priority_more (const struct list_elem *a_, const struct list_elem *b_,
|
||||
void *aux UNUSED);
|
||||
int thread_get_priority (void);
|
||||
void thread_set_priority (int);
|
||||
void thread_recalculate_priority (void);
|
||||
|
||||
int thread_get_nice (void);
|
||||
void thread_set_nice (int);
|
||||
|
||||
Reference in New Issue
Block a user