mq_open from rtai_mq.h problem

Teresa Noviello lunicateresa at gmail.com
Fri Jul 7 15:15:09 CEST 2006


Hi, i have a simple application (i'm trying with this because i have the
same mq_open problem with a rtnet RTT example):

------- prova. c ----------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <rtai_mq.h>
#include <errno.h>
#include <signal.h>
#include <rtai_lxrt.h>
#include <rtnet.h>
#include <time.h>

int main(){

mqd_t mq;
//struct sched_param param = { .sched_priority = 1 };
    char mqname[16];
    struct mq_attr mqattr;
    int ret;

snprintf(mqname, sizeof(mqname), "rtt-sender-%d", getpid());

//debug
printf("Terminata la inizializzazione di nome di coda di messaggi\n");

    mqattr.mq_flags   = 0;
    mqattr.mq_maxmsg  = 100;
    //mqattr.mq_msgsize = sizeof(struct packet_stats);
    mqattr.mq_msgsize = sizeof(100);
    mqattr.mq_curmsgs = 0;

//debug
printf("Terminata inizializzazione attributi della coda di messaggi\n");

//debug
//printf("Momento di chiamata della mq_open, tolta per prova\n");
    mq = mq_open(mqname, O_RDWR | O_CREAT | O_EXCL, 0600, &mqattr);

//debug
printf("Terminata la mq_open\n");

    //if (mq == (mqd_t)-1) {
    if(mq<0){
        perror("opening mqueue failed");
        //close(sock);
        return 1;
    }

printf("mq_open andata a buon fine, programma terminato\n");
      return 0;
}

***-------------***

----my compile-commands------

gcc -c -Wall -ggdb -o prova.o -I/usr/realtime/include
-I/usr/src/rtnet/trunk/rtnet/stack/include prova.c
gcc -o prova -L/usr/realtime/lib -llxrt -lrtdm -lrt prova.o

(i got only a warning on variable ret not used)
***-------------***

-------lsmod at compile time and run time --------
rtai_mq
rtipv4
rtnet
rtai_rtdm
rtai_sem
rtai_lxrt
rtai_up
rtai_hal

(some rtnet modules are inserted from previous tests...)
***-------------***

----gdb command file-------------------------------
file prova

b rt_make_hard_real_time
b rt_return_linux_syscall
b rtai_lxrt
b getpid
b mq_open
***-------------***

I have segmentation fault on running the program "prova", i write the gdb
output, following.

---gdb output-----

root at rt_linux-1 # gdb --exec=prova --command=breaks
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux".
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Function "rt_make_hard_real_time" not defined.
Breakpoint 1 at 0x804879a: file rtai_lxrt.h, line 206.
Breakpoint 2 at 0x8048806: file rtai_lxrt.h, line 679.
Breakpoint 3 at 0x804879a: file rtai_lxrt.h, line 206.
Function "getpid" not defined.
Function "mq_open" not defined.
(gdb)
(gdb) b getpid
Function "getpid" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 4 (getpid) pending.
(gdb) b mq_open
Function "mq_open" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 5 (mq_open) pending.
(gdb) run
Starting program:
/usr/src/rtnet_latest_version/trunk/rtnet/examples/xenomai/myposix/provamq2/prova
[Thread debugging using libthread_db enabled]
[New Thread -1209898688 (LWP 3469)]
Breakpoint 6 at 0xb7ec1cc0
Pending breakpoint "getpid" resolved
Breakpoint 7 at 0xb7f689b6
Pending breakpoint "mq_open" resolved
[Switching to Thread -1209898688 (LWP 3469)]

Breakpoint 6, 0xb7ec1cc0 in getpid () from /lib/tls/libc.so.6
(gdb) c
Continuing.
Terminata la inizializzazione di nome di coda di messaggi
Terminata inizializzazione attributi della coda di messaggi

Breakpoint 7, 0xb7f689b6 in mq_open () from /usr/realtime/lib/liblxrt.so.1
(gdb) backtrace
#0  0xb7f689b6 in mq_open () from /usr/realtime/lib/liblxrt.so.1
#1  0x08048731 in main () at prova.c:45
(gdb) c
Continuing.
Couldn't get registers: No such process.
(gdb) frame
No selected frame.
(gdb) backtrace
Cannot fetch general-purpose registers for thread -1209898688: generic error
(gdb) quit
The program is running.  Exit anyway? (y or n) y
Quitting: thread_db_get_info: cannot get thread info: generic error
root at rt_linux-1 #
root at rt_linux-1
#

***-------------***

The problem is in mq_open.

Where i do wrong?

What's missing?
Could anyone help me on mq_open?

-- 
Teresa Noviello
Chiedersi Sempre:"Avro' il tempo di rifarlo?"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.rtai.org/pipermail/rtai/attachments/20060707/1708490e/attachment.htm 


More information about the Rtai mailing list