Mode Switch

Leandro Bucci guestleandro11 at
Sun Jan 3 21:29:24 CET 2021

Hi, I have a strange behavior regarding the "mode switch".
In the attached code, the task should never switch to the Linux domain, but
instead I have a value of MSW = 2.
How is it possible?
Even if I do a printf in the task I always get MSW = 2.
I can't understand where the problem is.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alchemy/task.h>
#include <alchemy/timer.h>

RT_TASK task;

void task_body(void *arg)
rt_task_inquire(NULL, &info);

int main()
int err;

err = rt_task_create(&task, "mytask", 0, 1, 0);
if (err != 0){
fprintf(stderr, "failed to create task\n");

err = rt_task_start(&task, &task_body, NULL);
if (err != 0){
fprintf(stderr, "failed to start task\n");

sleep(5); //sleep for 5 seconds

printf("mode switch = %d\n", (int)(info.stat.msw));


More information about the Xenomai mailing list