Fix Bug in recalculating priority, uses 'elem' instead of 'donor_elem', w/ T
This commit is contained in:
@@ -70,6 +70,8 @@ static void *alloc_frame (struct thread *, size_t size);
|
||||
static void schedule (void);
|
||||
void thread_schedule_tail (struct thread *prev);
|
||||
static tid_t allocate_tid (void);
|
||||
static bool donor_priority_less (const struct list_elem *a_,
|
||||
const struct list_elem *b_, void *aux UNUSED);
|
||||
|
||||
/* Initializes the threading system by transforming the code
|
||||
that's currently running into a thread. This can't work in
|
||||
@@ -370,6 +372,19 @@ priority_more (const struct list_elem *a_, const struct list_elem *b_,
|
||||
return a->priority > b->priority;
|
||||
}
|
||||
|
||||
/* Function that compares the two threads associated with the provided
|
||||
pointers to their 'donor_elem' member. Returns true if the thread associated
|
||||
with a_ has a lower priority than that of b_. */
|
||||
static bool
|
||||
donor_priority_less (const struct list_elem *a_, const struct list_elem *b_,
|
||||
void *aux UNUSED)
|
||||
{
|
||||
struct thread *a = list_entry (a_, struct thread, donor_elem);
|
||||
struct thread *b = list_entry (b_, struct thread, donor_elem);
|
||||
|
||||
return a->priority < b->priority;
|
||||
}
|
||||
|
||||
/* Sets the current thread's base priority to new_base_priority.
|
||||
Updates the current thread's effective priority if necessary. */
|
||||
void
|
||||
@@ -408,7 +423,7 @@ thread_recalculate_priority (void)
|
||||
if (!list_empty (&t->donors_list))
|
||||
{
|
||||
int max_donated_priority =
|
||||
list_entry (list_max (&t->donors_list, priority_more, NULL),
|
||||
list_entry (list_max (&t->donors_list, donor_priority_less, NULL),
|
||||
struct thread, donor_elem)->priority;
|
||||
|
||||
if (max_donated_priority > t->priority)
|
||||
|
||||
Reference in New Issue
Block a user