void priv_set_scheduling_param(void * args){ priv_set_pthread_scheduling_param_t * p = (priv_set_pthread_scheduling_param_t*)args; int id; id = p->tid; PTHREAD_ATTR_SET_SCHED_POLICY( (&(sched_table[id].attr)), p->policy); memcpy((void*)&sched_table[id].attr.schedparam, p->param, sizeof(struct sched_param)); if ( p->policy == SCHED_FIFO ){ task_assert_isfifo(id); } else { task_deassert_isfifo(id); } }
/*! \details This function sets the scheduling policy in \a attr with \a policy. * \return Zero on success or -1 with errno set to: * - EINVAL: \a attr does not refer to an initialized thread attribute object * - EINVAL: \a policy does not refer to a valid policy. */ int pthread_attr_setschedpolicy(pthread_attr_t *attr /*! a pointer to the attributes structure */, int policy /*! the new policy value (SCHED_FIFO, SCHED_RR, or SCHED_OTHER) */){ if ( check_initialized(attr) < 0 ){ return -1; } switch(policy){ case SCHED_FIFO: case SCHED_RR: case SCHED_OTHER: PTHREAD_ATTR_SET_SCHED_POLICY(attr, policy); return 0; default: errno = EINVAL; return -1; } }