From 6b9b671368faeb19e4fab0bd0b3e3c66e782727d Mon Sep 17 00:00:00 2001 From: Themis Date: Thu, 17 Oct 2024 20:01:39 +0100 Subject: [PATCH] Update sema_up to properly yield during execution of an interrupt handler --- src/threads/synch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/threads/synch.c b/src/threads/synch.c index 374817f..d773824 100644 --- a/src/threads/synch.c +++ b/src/threads/synch.c @@ -120,7 +120,10 @@ sema_up (struct semaphore *sema) sema->value++; intr_set_level (old_level); - thread_yield (); + if (intr_context ()) + intr_yield_on_return (); + else + thread_yield (); } static void sema_test_helper (void *sema_);