Update thread_create to only yield CPU to the new thread if necessary

This commit is contained in:
sBubshait
2024-10-25 15:47:19 +01:00
parent 81309dcda9
commit 30ab3ae861

View File

@@ -261,6 +261,10 @@ thread_create (const char *name, int priority,
/* Add to run queue. */ /* Add to run queue. */
thread_unblock (t); thread_unblock (t);
/* Yield if the newly created thread has higher priority than the current
thread. */
if (t->priority > thread_current ()->priority)
thread_yield (); thread_yield ();
return tid; return tid;