From 3b1f42b89770bde81068e5e157b10cf911c96b6c Mon Sep 17 00:00:00 2001
From: hugno051 <hugno051@tlvm-4-2-4.ad.liu.se>
Date: Fri, 27 Sep 2024 14:27:03 +0200
Subject: [PATCH] sleep_element

---
 devices/timer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/devices/timer.c b/devices/timer.c
index 8205bf7..2177686 100644
--- a/devices/timer.c
+++ b/devices/timer.c
@@ -96,7 +96,7 @@ void timer_sleep(int64_t ticks)
     current_thread->wakeup_time = start + ticks;
 
     // 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
     thread_block();
@@ -174,7 +174,7 @@ static void timer_interrupt(struct intr_frame* args UNUSED)
 	ticks++;
 	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)
 		{
 			list_pop_front(&ready_to_run);
@@ -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)
 {
-	struct thread *thread_a = list_entry(a, struct thread, elem);
-	struct thread *thread_b = list_entry(b, struct thread, elem);
+	struct thread *thread_a = list_entry(a, struct thread, sleep_element);
+	struct thread *thread_b = list_entry(b, struct thread, sleep_element);
 
 	return thread_a->wakeup_time < thread_b->wakeup_time;
 }
\ No newline at end of file
-- 
GitLab