summaryrefslogtreecommitdiff
path: root/tests/priority1.c
diff options
context:
space:
mode:
authorrpj <rpj>2003-09-18 02:31:39 +0000
committerrpj <rpj>2003-09-18 02:31:39 +0000
commitaf1871fba4fc253b5a31e4a0eed667fe79f534d7 (patch)
tree1242599d7334ae50c5c05f9b23b52876e4287924 /tests/priority1.c
parentfac679912b15dd89cafdb09bf873d7eacc80a05e (diff)
Cleanup and fixes to thread priority management. Other minor changes.snap-2003-09-18
Diffstat (limited to 'tests/priority1.c')
-rw-r--r--tests/priority1.c21
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, &param) == 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;