Invert the priority scheme, so that PRI_MIN is now the lowest priority
[pintos-anon] / src / tests / threads / alarm-priority.c
index 291861fd276f172ee8bd55258ecfea118cff90f6..4839ecdfc81491d36c656ea4ef98761cf5206616 100644 (file)
@@ -1,3 +1,6 @@
+/* Checks that when the alarm clock wakes up threads, the
+   higher-priority threads run first. */
+
 #include <stdio.h>
 #include "tests/threads/tests.h"
 #include "threads/init.h"
@@ -23,13 +26,13 @@ test_alarm_priority (void)
   
   for (i = 0; i < 10; i++) 
     {
-      int priority = (i + 5) % 10 + PRI_DEFAULT + 1;
+      int priority = PRI_DEFAULT - (i + 5) % 10 - 1;
       char name[16];
       snprintf (name, sizeof name, "priority %d", priority);
       thread_create (name, priority, alarm_priority_thread, NULL);
     }
 
-  thread_set_priority (PRI_MAX);
+  thread_set_priority (PRI_MIN);
 
   for (i = 0; i < 10; i++)
     sema_down (&wait_sema);