123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- #include "test.h"
- enum
- {
- PTW32TEST_THREAD_INIT_PRIO = 0,
- PTW32TEST_MAXPRIORITIES = 512
- };
- static void * func(void * arg)
- {
- int policy;
- struct sched_param param;
- assert(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0);
- return (void *) param.sched_priority;
- }
- int pthread_test_inherit1()
- {
- pthread_t t;
- pthread_t mainThread = pthread_self();
- pthread_attr_t attr;
- int result = 0;
- struct sched_param param;
- struct sched_param mainParam;
- int prio;
- int policy;
- int inheritsched = -1;
- assert(pthread_attr_init(&attr) == 0);
- assert(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED) == 0);
- assert(pthread_attr_getinheritsched(&attr, &inheritsched) == 0);
- assert(inheritsched == PTHREAD_INHERIT_SCHED);
- for (prio = pte_osThreadGetMinPriority();
- prio <= pte_osThreadGetMaxPriority();
- prio++)
- {
- mainParam.sched_priority = prio;
-
- assert(pthread_setschedparam(mainThread, SCHED_OTHER, &mainParam) == 0);
- assert(pthread_getschedparam(mainThread, &policy, &mainParam) == 0);
- assert(policy == SCHED_OTHER);
-
- assert(mainParam.sched_priority == prio);
- pte_osThreadSetPriority(pte_osThreadGetHandle(), prio);
- assert(pte_osThreadGetPriority(pte_osThreadGetHandle()) == prio);
- for (param.sched_priority = prio;
- param.sched_priority <= pte_osThreadGetMaxPriority();
- param.sched_priority++)
- {
-
- assert(pthread_attr_setschedparam(&attr, ¶m) == 0);
- assert(pthread_create(&t, &attr, func, NULL) == 0);
- pthread_join(t, (void **)&result);
- assert((int) result == mainParam.sched_priority);
- }
- }
- return 0;
- }
|