Пример #1
0
int _rtapi_task_self(void) {
#ifdef HAVE_RTAPI_TASK_SELF_HOOK
    return _rtapi_task_self_hook();
#else
    /* not implemented */
    return -EINVAL;
#endif
}
Пример #2
0
int _rtapi_task_update_stats_hook(void)
{
    int task_id = _rtapi_task_self_hook();

    // paranoia
    if ((task_id < 0) || (task_id > RTAPI_MAX_TASKS)) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"_rtapi_task_update_stats_hook: BUG -"
			" task_id out of range: %d\n",
			task_id);
	return -ENOENT;
    }

    struct rusage ru;

    if (getrusage(RUSAGE_THREAD, &ru)) {
	rtapi_print_msg(RTAPI_MSG_ERR,"getrusage(): %d - %s\n",
			errno, strerror(-errno));
	return errno;
    }

    rtapi_threadstatus_t *ts = &global_data->thread_status[task_id];

    ts->flavor.rtpreempt.utime_usec = ru.ru_utime.tv_usec;
    ts->flavor.rtpreempt.utime_sec  = ru.ru_utime.tv_sec;

    ts->flavor.rtpreempt.stime_usec = ru.ru_stime.tv_usec;
    ts->flavor.rtpreempt.stime_sec  = ru.ru_stime.tv_sec;

    ts->flavor.rtpreempt.ru_minflt = ru.ru_minflt;
    ts->flavor.rtpreempt.ru_majflt = ru.ru_majflt;
    ts->flavor.rtpreempt.ru_nsignals = ru.ru_nsignals;
    ts->flavor.rtpreempt.ru_nivcsw = ru.ru_nivcsw;
    ts->flavor.rtpreempt.ru_nivcsw = ru.ru_nivcsw;

    ts->num_updates++;

    return task_id;
}
Пример #3
0
int _rtapi_trap_handler(unsigned event, unsigned domid, void *data) {
    struct pt_regs *regs = data;
    xnthread_t *thread = xnpod_current_thread(); ;

    int task_id = _rtapi_task_self_hook();

    rtapi_exception_detail_t detail = {0};

    detail.task_id = task_id;
    detail.error_code = thread->errcode;

    detail.flavor.xeno.event = event;
    detail.flavor.xeno.domid = domid;
    detail.flavor.xeno.ip = (exc_register_t) regs->ip;
    detail.flavor.xeno.sp = (exc_register_t) regs->sp;

    if (rt_exception_handler)
	rt_exception_handler(XK_TRAP, &detail,
			     (task_id > -1) ?
			     &global_data->thread_status[task_id] : NULL);

    // forward to default Xenomai trap handler
    return ((rthal_trap_handler_t) old_trap_handler)(event, domid, data);
}