1 /* Problem 1-3: Priority Scheduling tests.
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>.
9 #include "threads/test.h"
11 #include "threads/synch.h"
12 #include "threads/thread.h"
14 static void test_preempt (void);
19 /* This test does not work with the MLFQS. */
20 ASSERT (!enable_mlfqs);
22 /* Make sure our priority is the default. */
23 ASSERT (thread_get_priority () == PRI_DEFAULT);
28 static thread_func simple_thread_func;
34 "Testing priority preemption.\n");
35 thread_create ("high-priority", PRI_DEFAULT + 1, simple_thread_func, NULL);
36 printf ("The high-priority thread should have already completed.\n"
37 "Priority preemption test done.\n");
41 simple_thread_func (void *aux UNUSED)
45 for (i = 0; i < 5; i++)
47 printf ("Thread %s iteration %d\n", thread_name (), i);
50 printf ("Thread %s done!\n", thread_name ());