[Xenomai] ERROR:rt_task_create failed: Operation not permitted

jj subot suprbot2015 at gmail.com
Thu Dec 31 09:01:59 CET 2015


Hi,

Happy new year!

I'm a newbie to xenomai and linux, so Help!

I  build the xenomai environment on raspberry 2:

xenomai 3+ raspbian linux 3.18.20

and then i build my test programe, i just try to create a rt task like this:


main.cpp:

/****************************************************************************/
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

#include <rtdm/rtdm.h>
#include <alchemy/sem.h>
#include <alchemy/mutex.h>
#include <alchemy/timer.h>

//cobalt
#include <sys/mman.h>
#include <unistd.h>

//trank
#include <trank/native/task.h>
#include <trank/rtdk.h>

#include <pthread.h>

RT_TASK my_task;

static int run = 1;

/****************************************************************************/

void my_task_proc(void *arg)
{
   rt_task_set_periodic(NULL, TM_NOW, 1000000*10); // ns  10ms

   while(run);
}


/****************************************************************************
 * Signal handler
 ***************************************************************************/

void signal_handler(int sig)
{
    run = 0;
}


/****************************************************************************
 * Main function
 ***************************************************************************/

int main(int argc, char *argv[])
{
    int ret;

    /* Perform auto-init of rt_print buffers if the task doesn't do so */
    rt_print_auto_init(1);

    signal(SIGTERM, signal_handler);
    signal(SIGINT, signal_handler);

    mlockall(MCL_CURRENT | MCL_FUTURE);

    ret = rt_task_create(&my_task, "my_task", 0, 80, T_FPU);
    if (ret < 0) {
        fprintf(stderr, "Failed to create task: %s\n", strerror(-ret));
        return -1;
    }

    printf("Starting my_task...\n");
    ret = rt_task_start(&my_task, &my_task_proc, NULL);
    if (ret < 0) {
        fprintf(stderr, "Failed to start task: %s\n", strerror(-ret));
        return -1;
    }

    while (run) {
        sched_yield();
    }

    printf("Deleting realtime task...\n");
    rt_task_delete(&my_task);

    return 0;
}

/****************************************************************************/

CmakeLists:

INCLUDE_DIRECTORIES(/usr/xenomai/include /usr/xenomai/include/xenomai
/usr/xenomai/include/cobalt /opt/etherlab/include)
LINK_DIRECTORIES(/usr/xenomai/lib)
ADD_EXECUTABLE(ecat_t1 main.cpp)
TARGET_LINK_LIBRARIES(ecat_t1 rt cobalt copperplate alchemy trank pthread)

When i run it,
Failed to create task: Operation not permitted
WHY!
HELP~


More information about the Xenomai mailing list