123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #include "pthread.h"
- #include "implement.h"
- #include "sched.h"
- int
- pthread_setschedparam (pthread_t thread, int policy,
- const struct sched_param *param)
- {
- int result;
-
- result = pthread_kill (thread, 0);
- if (0 != result)
- {
- return result;
- }
-
- if (policy < SCHED_MIN || policy > SCHED_MAX)
- {
- return EINVAL;
- }
-
- if (policy != SCHED_OTHER)
- {
- return ENOTSUP;
- }
- return (pte_setthreadpriority (thread, policy, param->sched_priority));
- }
- int
- pte_setthreadpriority (pthread_t thread, int policy, int priority)
- {
- int prio;
- int result;
- pte_thread_t * tp = (pte_thread_t *) thread;
- prio = priority;
-
- if (prio < sched_get_priority_min (policy) ||
- prio > sched_get_priority_max (policy))
- {
- return EINVAL;
- }
- result = pthread_mutex_lock (&tp->threadLock);
- if (0 == result)
- {
-
- if (0 != pte_osThreadSetPriority(tp->threadId, prio))
- {
- result = EINVAL;
- }
- else
- {
-
- tp->sched_priority = priority;
- }
- (void) pthread_mutex_unlock (&tp->threadLock);
- }
- return result;
- }
|