From 57c893ae56f151efc96fabebbb4c8ec039cb56ef Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 8 May 2012 02:35:22 +0200 Subject: * fixed sema_up which didn't yield the cpu * fixed wrong condition comperator * renamed the comperator functions to better explain their compare element * current status: 3 of 18 tests failed --- threads/thread.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'threads/thread.c') diff --git a/threads/thread.c b/threads/thread.c index 17d21bd..a7db106 100644 --- a/threads/thread.c +++ b/threads/thread.c @@ -73,11 +73,11 @@ static tid_t allocate_tid (void); /* comparison function for our descending ordered ready list. */ bool -priority_list_cmp_greater(const struct list_elem *a, const struct list_elem *b, +thread_priority_cmp_greater(const struct list_elem *a, const struct list_elem *b, void *AUX UNUSED) { - struct thread *t1 = list_entry (a, struct thread, elem); - struct thread *t2 = list_entry (b, struct thread, elem); + const struct thread *t1 = list_entry (a, struct thread, elem); + const struct thread *t2 = list_entry (b, struct thread, elem); return (t1->priority > t2->priority); } @@ -264,7 +264,7 @@ thread_unblock (struct thread *t) old_level = intr_disable (); ASSERT (t->status == THREAD_BLOCKED); /* add thread to our ordered ready_list */ - list_insert_ordered (&ready_list, &t->elem, &priority_list_cmp_greater, NULL); + list_insert_ordered (&ready_list, &t->elem, &thread_priority_cmp_greater, NULL); t->status = THREAD_READY; intr_set_level (old_level); } @@ -335,7 +335,7 @@ thread_yield (void) old_level = intr_disable (); if (cur != idle_thread) - list_insert_ordered (&ready_list, &cur->elem, &priority_list_cmp_greater, NULL); + list_insert_ordered (&ready_list, &cur->elem, &thread_priority_cmp_greater, NULL); cur->status = THREAD_READY; schedule (); intr_set_level (old_level); @@ -390,7 +390,7 @@ thread_other_set_priority (struct thread *t, int new_priority) { /* sort our ordered list */ list_remove (&t->elem); - list_insert_ordered (&ready_list, &t->elem, &priority_list_cmp_greater, NULL); + list_insert_ordered (&ready_list, &t->elem, &thread_priority_cmp_greater, NULL); } else if (t->status == THREAD_RUNNING && !list_empty (&ready_list)) { -- cgit v1.2.3