123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <errno.h>
- #include <sched.h>
- #include <string.h>
- #include "pthreadP.h"
- #include <lowlevellock.h>
- int
- attribute_protected
- __pthread_setschedparam (
- pthread_t threadid,
- int policy,
- const struct sched_param *param)
- {
- struct pthread *pd = (struct pthread *) threadid;
-
- if (INVALID_TD_P (pd))
-
- return ESRCH;
- int result = 0;
- lll_lock (pd->lock, LLL_PRIVATE);
- struct sched_param p;
- const struct sched_param *orig_param = param;
-
- if (__builtin_expect (pd->tpp != NULL, 0)
- && pd->tpp->priomax > param->sched_priority)
- {
- p = *param;
- p.sched_priority = pd->tpp->priomax;
- param = &p;
- }
-
- if (__builtin_expect (__sched_setscheduler (pd->tid, policy,
- param) == -1, 0))
- result = errno;
- else
- {
-
- pd->schedpolicy = policy;
- memcpy (&pd->schedparam, orig_param, sizeof (struct sched_param));
- pd->flags |= ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET;
- }
- lll_unlock (pd->lock, LLL_PRIVATE);
- return result;
- }
- strong_alias (__pthread_setschedparam, pthread_setschedparam)
|