Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
lower priority
Browse files Browse the repository at this point in the history
  • Loading branch information
grantborthwick committed Oct 5, 2012
1 parent d1dd5e9 commit dd45c83
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/threads/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,28 @@ thread_foreach (thread_action_func *func, void *aux)
void
thread_set_priority (int new_priority)
{
thread_current ()->priority = new_priority;
//todo check if lower than any ready thread.
thread_current ()->priority = new_priority;
struct list_elem* e;
struct thread* e2;
bool y = false;
for (e = (list_begin (&ready_list)); e!= list_end (&ready_list);
e = list_next(e))
{
e2 = list_entry (e, struct thread, elem);
if ((e2->priority) >(thread_current ()->priority)){
y = true;
break;
}
}
if (y){thread_yield();}
}

/* Returns the current thread's priority. */
int
thread_get_priority (void)
{
//todo recursive with list or number check
return thread_current ()->priority;
}

Expand Down

0 comments on commit dd45c83

Please sign in to comment.