From af1871fba4fc253b5a31e4a0eed667fe79f534d7 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 18 Sep 2003 02:31:39 +0000 Subject: Cleanup and fixes to thread priority management. Other minor changes. --- tests/inherit1.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/inherit1.c') diff --git a/tests/inherit1.c b/tests/inherit1.c index 364aa74..288919c 100644 --- a/tests/inherit1.c +++ b/tests/inherit1.c @@ -97,21 +97,22 @@ void * getValidPriorities(void * arg) { int prioSet; - pthread_t threadID = pthread_self(); - HANDLE threadH = pthread_getw32threadhandle_np(threadID); + pthread_t thread = pthread_self(); + HANDLE threadH = pthread_getw32threadhandle_np(thread); + struct sched_param param; for (prioSet = minPrio; prioSet <= maxPrio; prioSet++) { - /* + /* * If prioSet is invalid then the threads priority is unchanged * from the previous value. Make the previous value a known * one so that we can check later. */ - SetThreadPriority(threadH, PTW32TEST_THREAD_INIT_PRIO); - SetThreadPriority(threadH, prioSet); - validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)] = GetThreadPriority(threadH); + param.sched_priority = prioSet; + assert(pthread_setschedparam(thread, SCHED_OTHER, ¶m) == 0); + validPriorities[prioSet+(PTW32TEST_MAXPRIORITIES/2)] = GetThreadPriority(threadH); } return (void *) 0; @@ -155,7 +156,9 @@ main() assert(pthread_setschedparam(mainThread, SCHED_OTHER, &mainParam) == 0); assert(pthread_getschedparam(mainThread, &policy, &mainParam) == 0); assert(policy == SCHED_OTHER); - assert(mainParam.sched_priority == + /* Priority returned below should be the level set by pthread_setschedparam(). */ + assert(mainParam.sched_priority == prio); + assert(GetThreadPriority(threadH) == validPriorities[prio+(PTW32TEST_MAXPRIORITIES/2)]); for (param.sched_priority = prio; -- cgit v1.2.3