M. Koehrer wrote:
> Hi Jan, hi everybody,
> 
> I have stripped down my program that is crashing Xenomai even further.
> (I have attached the complete source code).
> No rtnet is required.
> Now I have the following real time task:
> 
> static void realtimetask(void *arg)
> {
>     system("ls -l");

If you want to use system (or any function calling fork, eg popen or
vfork) with Xenomai, you have to make sure to fault all pages mapped
with write permission after the fork before trying to use services in
priimary mode, because fork write protects all pages with write
permission and notably the threads stacks. A piece of code that faults
all pages follows.

static void fault_vm(void)
{
        FILE *maps = fopen("/proc/self/maps", "r");
        unsigned begin, end, pagesize=getpagesize();
        char buffer[128];
        int rc;

        if (!maps) {
                perror("fopen");
                exit(EXIT_FAILURE);
        }

        while ((rc = fscanf(maps, "%x-%x",&begin, &end) == 2)) {
                fgets(buffer, 128, maps);

                if(buffer[2] != 'w')
                        continue;

                for (; begin != end; begin += pagesize)
                        *(volatile int *) begin = *(volatile int *) begin;
        }

        fclose(maps);
}


-- 
                                                 Gilles Chanteperdrix

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to