[FUSION-0.8.1]Bug with accessing RT_SEM from user space

Dmitry Adamushko dmitry.adamushko at datacon.at
Wed Aug 17 16:04:03 CEST 2005


Hello,

> Hello,
>
> I observe a following behaviour on fusion-0.8.3 and fusion-0.8.1.
>
> Userspace application forks a RT thread, which reads some datas,
> syncronizing due a RT_SEM.
>
> [skip-skip-skip]
>
> If I comment out lines with rt_sem_bind, rt_sem_p rt_sem_unbind, it
> works like a charm!

What code kicks the semaphore and how? Posting the exact pieces of the code
might help, especially a code-minimized example that still reproduces the
problem.

Please, check whether the attached below example works (it does pretty the
same work)?

TIA,


---
Best regards,
Dmitry


---------------------------
#include <rtai/task.h>
#include <rtai/sem.h>
#include <rtai/mutex.h>

#include <stdio.h>

RT_TASK master, slave;
RT_SEM  sem;

void task_body (void *cookie)

{
    RT_SEM lsem;
    int ret;

    ret = rt_sem_bind(&lsem, "sem");
    if (ret)
        {
        printf("1) rt_sem_bind() == %i\n", ret);
        return;
        }

    ret = rt_sem_p(&lsem, TM_INFINITE);
    if (ret)
        {
        printf("2) rt_sem_v() == %i\n", ret);
        goto out;
        }

out:
    rt_sem_unbind(&lsem);

    printf("lalalala\n");
    printf("lulululu\n");
    rt_task_delete(NULL);
}


int main (int argc, char *argv[])

{
    int err, i;


    err = rt_task_shadow(&master, "master", 11, 0);
    if (err)
        {
        printf("rt_task_shadow() == %i\n", err);
        return;
        }

    err = rt_sem_create(&sem, "sem", 0, S_FIFO);
    if (err)
        {
        printf("rt_sem_create() == %i\n", err);
        return;
        }

    err = rt_task_spawn(&slave, "slave", 0, 10, 0,
                &task_body, NULL);
    if (err)
        {
        printf("rt_sem_create() == %i\n", err);
        return;
        }

    sleep(3);

    rt_sem_v(&sem);

    sleep(3);

    rt_sem_delete(&sem);

    return 0;
}
---------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.rtai.org/pipermail/rtai/attachments/20050817/0e78bfe2/attachment.htm 


More information about the Rtai mailing list