00001 /* Verifies that lowering a thread's priority so that it is no 00002 longer the highest-priority thread in the system causes it to 00003 yield immediately. */ 00004 00005 #include <stdio.h> 00006 #include "tests/threads/tests.h" 00007 #include "threads/init.h" 00008 #include "threads/thread.h" 00009 00010 static thread_func changing_thread; 00011 00012 void 00013 test_priority_change (void) 00014 { 00015 /* This test does not work with the MLFQS. */ 00016 ASSERT (!thread_mlfqs); 00017 00018 msg ("Creating a high-priority thread 2."); 00019 thread_create ("thread 2", PRI_DEFAULT + 1, changing_thread, NULL); 00020 msg ("Thread 2 should have just lowered its priority."); 00021 thread_set_priority (PRI_DEFAULT - 2); 00022 msg ("Thread 2 should have just exited."); 00023 } 00024 00025 static void 00026 changing_thread (void *aux UNUSED) 00027 { 00028 msg ("Thread 2 now lowering priority."); 00029 thread_set_priority (PRI_DEFAULT - 1); 00030 msg ("Thread 2 exiting."); 00031 }