diff options
Diffstat (limited to 'tests/priority1.c')
-rw-r--r-- | tests/priority1.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/priority1.c b/tests/priority1.c index 48af6f7..1dc6ea7 100644 --- a/tests/priority1.c +++ b/tests/priority1.c @@ -101,6 +101,9 @@ getValidPriorities(void * arg) pthread_t threadID = pthread_self(); HANDLE threadH = pthread_getw32threadhandle_np(threadID); + printf("Using GetThreadPriority\n"); + printf("%10s %10s\n", "Set value", "Get value"); + for (prioSet = minPrio; prioSet <= maxPrio; prioSet++) @@ -110,9 +113,13 @@ getValidPriorities(void * arg) * from the previous value. Make the previous value a known * one so that we can check later. */ - SetThreadPriority(threadH, PTW32TEST_THREAD_INIT_PRIO); + if (prioSet < 0) + SetThreadPriority(threadH, THREAD_PRIORITY_LOWEST); + else + SetThreadPriority(threadH, THREAD_PRIORITY_HIGHEST); SetThreadPriority(threadH, prioSet); validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)] = GetThreadPriority(threadH); + printf("%10d %10d\n", prioSet, validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)]); } return (void *) 0; @@ -140,15 +147,23 @@ main() SetThreadPriority(pthread_getw32threadhandle_np(pthread_self()), PTW32TEST_THREAD_INIT_PRIO); + printf("Using pthread_getschedparam\n"); + printf("%10s %10s\n", "Set value", "Get value"); + for (param.sched_priority = minPrio; param.sched_priority <= maxPrio; param.sched_priority++) { assert(pthread_attr_setschedparam(&attr, ¶m) == 0); assert(pthread_create(&t, &attr, func, (void *) &attr) == 0); + + assert(GetThreadPriority(pthread_getw32threadhandle_np(t)) + == validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]); + assert(pthread_join(t, &result) == 0); - assert((int) result == - validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]); + + assert(param.sched_priority == (int) result); + printf("%10d %10d\n", param.sched_priority, (int) result); } return 0; |