From 8b3f9e353f5724d345185442ddbfa42aaf2d34a1 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 16 Oct 2024 07:33:24 +0100 Subject: [PATCH] Update creating thread to yield if the new thread has higher priority --- src/threads/thread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/threads/thread.c b/src/threads/thread.c index 2d931e2..96d72be 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -223,6 +223,10 @@ thread_create (const char *name, int priority, /* Add to run queue. */ thread_unblock (t); + /* Yield if the new thread has a higher priority than the current thread. */ + if (priority > thread_get_priority ()) + thread_yield (); + return tid; }