X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Fthreads%2Falarm-priority.c;h=4839ecdfc81491d36c656ea4ef98761cf5206616;hb=e373cd64cfe799b3cb148e1117f3b3184b5a6457;hp=379f49213b136f1f7d53f87ddf176a17ea3ac37e;hpb=4ebf33908a571a7cde93fe618902b044e3633cdf;p=pintos-anon diff --git a/src/tests/threads/alarm-priority.c b/src/tests/threads/alarm-priority.c index 379f492..4839ecd 100644 --- a/src/tests/threads/alarm-priority.c +++ b/src/tests/threads/alarm-priority.c @@ -1,3 +1,6 @@ +/* Checks that when the alarm clock wakes up threads, the + higher-priority threads run first. */ + #include #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); @@ -39,7 +42,7 @@ static void alarm_priority_thread (void *aux UNUSED) { /* Busy-wait until the current time changes. */ - int64_t start_time; + int64_t start_time = timer_ticks (); while (timer_elapsed (start_time) == 0) continue;