コード例 #1
0
ファイル: fosi_internal.cpp プロジェクト: fengzhuye/rtt
        // we could implement here the interrupt shield logic.
        INTERNAL_QUAL int rtos_task_set_scheduler(RTOS_TASK* t, int sched_type) {
            // xenoptr was initialised from the thread wrapper.
            if (t->xenoptr != rt_task_self() ) {
                return -1;
            }

            if ( rtos_task_check_scheduler( &sched_type ) == -1)
                return -1;

#if ((CONFIG_XENO_VERSION_MAJOR*1000)+(CONFIG_XENO_VERSION_MINOR*100)+CONFIG_XENO_REVISION_LEVEL) < 2600
            if (sched_type == SCHED_XENOMAI_HARD) {
                if ( rt_task_set_mode( 0, T_PRIMARY, 0 ) == 0 ) {
                    t->sched_type = SCHED_XENOMAI_HARD;
                    return 0;
                } else {
                    return -1;
                }
            } else {
                if ( sched_type == SCHED_XENOMAI_SOFT) {
                    // This mode setting is only temporary. See rtos_task_wait_period() as well !
                    if (rt_task_set_mode( T_PRIMARY, 0, 0 ) == 0 ) {
                        t->sched_type = SCHED_XENOMAI_SOFT;
                        return 0;
                    } else {
                        return -1;
                    }
                }
            }
            assert(false);
            return -1;
#else
	    t->sched_type = sched_type;
	    return 0;
#endif
        }
コード例 #2
0
ファイル: fosi_internal.cpp プロジェクト: fengzhuye/rtt
	INTERNAL_QUAL int rtos_task_check_priority(int* scheduler, int* priority)
    {
        int ret = 0;
        // check scheduler first.
        ret = rtos_task_check_scheduler(scheduler);

        // correct priority
        // Hard & Soft:
#if ((CONFIG_XENO_VERSION_MAJOR*10000)+(CONFIG_XENO_VERSION_MINOR*100)+CONFIG_XENO_REVISION_LEVEL) >= 20500
        const int minprio = 0;
#else
        const int minprio = 1;
#endif
        if (*priority < minprio){
            log(Warning) << "Forcing priority ("<<*priority<<") of thread to " << minprio <<"." <<endlog();
            *priority = minprio;
            ret = -1;
        }
        if (*priority > 99){
            log(Warning) << "Forcing priority ("<<*priority<<") of thread to 99." <<endlog();
            *priority = 99;
            ret = -1;
        }
        return ret;
    }
コード例 #3
0
 INTERNAL_QUAL int rtos_task_set_scheduler(RTOS_TASK* t, int s) {
     if ( t->rtaitask == 0 || t->rtaitask != rt_buddy() ) {
         return -1;
     }
     if (rtos_task_check_scheduler(&s) == -1)
         return -1;
     if (s == SCHED_LXRT_HARD)
         rt_make_hard_real_time();
     else if ( s == SCHED_LXRT_SOFT)
         rt_make_soft_real_time();
     return 0;
 }
コード例 #4
0
	INTERNAL_QUAL int rtos_task_check_priority(int* scheduler, int* priority)
    {
        int ret = 0;
        // check scheduler first.
        ret = rtos_task_check_scheduler(scheduler);

        // correct priority
        if (*scheduler == SCHED_OTHER) {
            if ( *priority != 0 ) {
                if (*priority != LowestPriority)
                    log(Warning) << "Forcing priority ("<<*priority<<") of thread with SCHED_OTHER policy to 0." <<endlog();
                *priority = 0;
                ret = -1;
            }
        } else {
            // SCHED_FIFO/SCHED_RR:
            if (*priority <= 0){
                log(Warning) << "Forcing priority ("<<*priority<<") of thread with !SCHED_OTHER policy to 1." <<endlog();
                *priority = 1;
                ret = -1;
            }
            if (*priority > 99){
                log(Warning) << "Forcing priority ("<<*priority<<") of thread with !SCHED_OTHER policy to 99." <<endlog();
                *priority = 99;
                ret = -1;
            }
            // and limit them according to pam_Limits (only if not root)
            if ( geteuid() != 0 
#ifdef ORO_OS_LINUX_CAP_NG
                 && !capng_have_capability(CAPNG_EFFECTIVE, CAP_SYS_NICE)
#endif
                 )
            {
                struct rlimit	r;
                if (0 == getrlimit(RLIMIT_RTPRIO, &r))
                {
                    if (*priority > (int)r.rlim_cur)
                    {
                        log(Warning) << "Forcing priority ("<<*priority<<") of thread with !SCHED_OTHER policy to the pam_limit of " << r.rlim_cur <<endlog();
                        *priority = r.rlim_cur;
                        ret = -1;
                    }
                }
                else
                {
                    // this should not be possible, but do something intelligent
                    *priority = 1;
                    ret = -1;
                }
            }
        }
        return ret;
    }
コード例 #5
0
 INTERNAL_QUAL int rtos_task_set_scheduler(RTOS_TASK* task, int sched_type) {
     int policy = -1;
     struct sched_param param;
     // first check the argument
     if ( task && task->thread != 0 && rtos_task_check_scheduler( &sched_type) == -1 )
         return -1;
     // if sched_type is different, the priority must change as well.
     if (pthread_getschedparam(task->thread, &policy, &param) == 0) {
         // now update the priority
         param.sched_priority = task->priority;
         rtos_task_check_priority( &sched_type, &param.sched_priority );
         // write new policy:
         return pthread_setschedparam( task->thread, sched_type, &param);
     }
     return -1;
 }
コード例 #6
0
ファイル: fosi_internal.cpp プロジェクト: jsreng/orocos-rtt
	INTERNAL_QUAL int rtos_task_check_priority(int* scheduler, int* priority)
        {
            int ret = 0;
            // check scheduler first.
            ret = rtos_task_check_scheduler(scheduler);

            if (*priority < 0){
                log(Warning) << "Forcing priority ("<<*priority<<") of thread to 0." <<endlog();
                *priority = 0;
                ret = -1;
            }
            if (*priority > 63){
                log(Warning) << "Forcing priority ("<<*priority<<") of thread to 63." <<endlog();
                *priority = 63;
                ret = -1;
            }
            return ret;
        }
コード例 #7
0
        INTERNAL_QUAL int rtos_task_check_priority(int* scheduler, int* priority)
        {
            int ret = 0;
            // check scheduler first.
            ret = rtos_task_check_scheduler(scheduler);

            // correct priority
            // Hard & Soft:
            if (*priority < 0){
                log(Warning) << "Forcing priority ("<<*priority<<") of thread to 0." <<endlog();
                *priority = 0;
                ret = -1;
            }
            if (*priority > 255){
                log(Warning) << "Forcing priority ("<<*priority<<") of thread to 255." <<endlog();
                *priority = 255;
                ret = -1;
            }
            return ret;
        }