Hi,

I did this little test :

Below I have attached two sources, one on the kernel side and one on the
user side.
I do here a very simple fifo handshaking test. I insert the kernel module
then I run the user program. When I do the test with the "THE BUG IS HERE"
line commented, I got :

[EMAIL PROTECTED]:~/test/pipe# ./user
user : j'ai envoyé A
user :j'ai bien reçu E
[EMAIL PROTECTED]:~/test/pipe# dmesg
hello world
kernel : j'ai bien reçu A
kernel : ret = 1
kernel :j'ai envoyé E

Now, when I uncomment the line :
[EMAIL PROTECTED]:~/test/pipe# ./user
user : j'ai envoyé A
[CRTL-C] because the user program is blocking ...
[EMAIL PROTECTED]:~/test/pipe# dmesg
hello world
kernel : j'ai bien reçu A
kernel : ret = -4
kernel :j'ai envoyé E


Now, ret=-4 is the code for -EINTR. According to the doc :
"-EINTR is returned if rt_task_unblock() has been called for the waiting
task before any data was available."

I cannot see where rt_task_unblock() could be called. What is wrong ?

Thanks for your help,
Jacques

==================================================================
Kernel module :
==================================================================

#include <native/task.h>
#include <native/pipe.h>
#include <rtdm/rtdm_driver.h>

#define TASK_PRIO 99
#define TASK_MODE T_FPU|T_CPU(0)
#define TASK_STKSZ 4096

RT_PIPE pipe1,pipe2;
RT_TASK task_desc;

void task_body (void *cookie)
{
        char buf,mesg;
        int err;

    mesg = 'E';
        /*lecture dans le pipe (TM_INFINITE : bloque la tâche s'il y a rien dans
         * le pipe)*/
        err = rt_pipe_read(&pipe1,&buf,sizeof(char),TM_INFINITE);


        rtdm_printk("kernel : j'ai bien reçu %c \n",buf);

        /* THE BUG IS HERE */
        err = rt_pipe_read(&pipe1,&buf,sizeof(char),TM_INFINITE);
        /* THE BUG IS HERE */

        rtdm_printk("kernel : ret = %d\n", err );

        /*écriture dans le pipe*/
        err = rt_pipe_write(&pipe2,&mesg,sizeof(char),P_NORMAL);

        rtdm_printk("kernel :j'ai envoyé %c \n",mesg);


}


int init_module(void)
{

        int err=0;


        printk("hello world\n");

        /*Création d'un pipe pour lecture*/
        err = rt_pipe_create(&pipe1,"MyPipe0",0,sizeof(char));
        if(err)
        {
                rtdm_printk("pipe MyPipe0 creation failure \n");
        }

        /*Création d'un pipe pour écriture*/
        err = rt_pipe_create(&pipe2,"MyPipe1",1,sizeof(char));
        if(err)
        {
                rtdm_printk("pipe MyPipe1 creation failure \n");
        }

        /*Création de la tâche*/
        err =
rt_task_create(&task_desc,"MyTaskName",TASK_STKSZ,TASK_PRIO,TASK_MODE);

        if (!err)
        {
                /*lancement de la tâche*/
                rt_task_start(&task_desc,&task_body,NULL);
        }

        return 0;

}


void cleanup_module(void)

{
        rt_task_delete(&task_desc);
        rt_pipe_delete(&pipe1);
        rt_pipe_delete(&pipe2);
}

===================================================

User program :

===================================================

#include <native/task.h>
#include <native/pipe.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>



int main()
{
        int pipe1,pipe2;
        char m2,m1='A';

        m2 = 0;

        /*Ouverture du device côté user pour écriture */
        pipe1 = open("/dev/rtp0",O_RDWR);

        /*Ouverture du device côté user pour lecture*/
        pipe2 = open("/dev/rtp1",O_RDONLY);

        /*écriture des données*/
        write(pipe1,&m1,sizeof(char));

        printf("user : j'ai envoyé %c \n",m1);

        /* lecture des données */
        read(pipe2,&m2,sizeof(char));

        printf("user :j'ai bien reçu %c \n",m2);


        close(pipe1);
        close(pipe2);
        return 0;
}
 ___________________________________________

   Prof. Jacques GANGLOFF

   Strasbourg I University
   LSIIT Laboratory, EAVR team
   Bd S. Brant
   BP 10413, 67412 ILLKIRCH cedex, FRANCE
   Tel : +33 (0)3 90 24 44 68
   Fax : +33 (0)3 90 24 44 80
   http://eavr.u-strasbg.fr
____________________________________________


_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to