Skip to content
Snippets Groups Projects
Commit 3b1f42b8 authored by hugno051's avatar hugno051
Browse files

sleep_element

parent 92035d54
No related branches found
No related tags found
No related merge requests found
...@@ -96,7 +96,7 @@ void timer_sleep(int64_t ticks) ...@@ -96,7 +96,7 @@ void timer_sleep(int64_t ticks)
current_thread->wakeup_time = start + ticks; current_thread->wakeup_time = start + ticks;
// Add the calling thread to the sleep queue // Add the calling thread to the sleep queue
list_insert_ordered(&ready_to_run, &current_thread->elem, thread_wakeup_compare, NULL); list_insert_ordered(&ready_to_run, &current_thread->sleep_element, thread_wakeup_compare, NULL);
// Block the calling thread // Block the calling thread
thread_block(); thread_block();
...@@ -174,7 +174,7 @@ static void timer_interrupt(struct intr_frame* args UNUSED) ...@@ -174,7 +174,7 @@ static void timer_interrupt(struct intr_frame* args UNUSED)
ticks++; ticks++;
while (!list_empty(&ready_to_run)) while (!list_empty(&ready_to_run))
{ {
struct thread * current_thread = list_entry(list_front(&ready_to_run), struct thread, elem); struct thread * current_thread = list_entry(list_front(&ready_to_run), struct thread, sleep_element);
if(current_thread->wakeup_time <= ticks) if(current_thread->wakeup_time <= ticks)
{ {
list_pop_front(&ready_to_run); list_pop_front(&ready_to_run);
...@@ -253,8 +253,8 @@ static void real_time_delay(int64_t num, int32_t denom) ...@@ -253,8 +253,8 @@ static void real_time_delay(int64_t num, int32_t denom)
bool thread_wakeup_compare(const struct list_elem* a, const struct list_elem* b, void* aux) bool thread_wakeup_compare(const struct list_elem* a, const struct list_elem* b, void* aux)
{ {
struct thread *thread_a = list_entry(a, struct thread, elem); struct thread *thread_a = list_entry(a, struct thread, sleep_element);
struct thread *thread_b = list_entry(b, struct thread, elem); struct thread *thread_b = list_entry(b, struct thread, sleep_element);
return thread_a->wakeup_time < thread_b->wakeup_time; return thread_a->wakeup_time < thread_b->wakeup_time;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment