Permalink
Browse files

lower priority

  • Loading branch information...
1 parent d1dd5e9 commit dd45c83b6527845ee08614c28849e8e04663a0ef @grantborthwick committed Oct 5, 2012
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/threads/thread.c
View
@@ -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;
}

0 comments on commit dd45c83

Please sign in to comment.