From 337f8828d95c170e4f9feb148c55fc85f4f1907a Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Tue, 15 Oct 2024 19:21:15 +0100 Subject: [PATCH] implement thread_get_nice, thread_set_nice and skeleton for calculate_priority --- src/threads/thread.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/threads/thread.c b/src/threads/thread.c index 30ca2bd..c74d86b 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -364,19 +364,27 @@ thread_get_priority (void) return thread_current ()->priority; } +/* Calculates priority for the current thread */ +int +calculate_priority (void) +{ + /* Not yet implemented */ + return 0; +} + /* Sets the current thread's nice value to NICE. */ void -thread_set_nice (int nice UNUSED) +thread_set_nice (int nice) { - /* Not yet implemented. */ + thread_current ()->nice = nice; + calculate_priority (); } /* Returns the current thread's nice value. */ int thread_get_nice (void) { - /* Not yet implemented. */ - return 0; + return thread_current ()->nice; } /* Returns 100 times the system load average. */