1 /* Ensures that a high-priority thread really preempts.
3 Based on a test originally submitted for Stanford's CS 140 in
4 winter 1999 by by Matt Franklin
5 <startled@leland.stanford.edu>, Greg Hutchins
6 <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
10 #include "tests/threads/tests.h"
11 #include "threads/init.h"
12 #include "threads/synch.h"
13 #include "threads/thread.h"
15 static thread_func simple_thread_func;
18 test_priority_preempt (void)
20 /* This test does not work with the MLFQS. */
21 ASSERT (!thread_mlfqs);
23 /* Make sure our priority is the default. */
24 ASSERT (thread_get_priority () == PRI_DEFAULT);
26 thread_create ("high-priority", PRI_DEFAULT + 1, simple_thread_func, NULL);
27 msg ("The high-priority thread should have already completed.");
31 simple_thread_func (void *aux UNUSED)
35 for (i = 0; i < 5; i++)
37 msg ("Thread %s iteration %d", thread_name (), i);
40 msg ("Thread %s done!", thread_name ());