ShabbyX / RTAI

(NO LONGER MAINTAINED) Clone of RTAI from https://www.rtai.org
28 stars 17 forks source link

Various questions #26

Closed ShabbyX closed 7 years ago

ShabbyX commented 8 years ago

From @mrudulachougule

Hi, I am working on rtai-4.1 version and i am able to compile rtai debian and installed on Ubuntu 14.04. Now I have below queries on rtai_lxrt module: 1) why rtai_lxrt.ko is soft link of rtai_sched.ko? 2) In rtai-3.8 version rtai_lxrt is not linked to any other module any specific reason? 3) I need rtai_lxrt individual module to be imported any idea how to do this? 4) I have python back end code which imports few of the module from rtai, since rtai_lxrt is not inserted so i'm not able to import the same? 5) can I include rtai_lxrt header file to resolve python and rtai binding issue? 6) CONFIG_RTAI_LXRT_USE_LINUX_SYSCALL option is not available to configure in rtai-4.1 but same is available, any idea how to enable / explicitly overwrite this option? 7) How to get rtai_lxrt.ko as application scheduler, without soft link of rtai_sched?

Please share your views to resolve these issues , I'm stuck!!! Appreciate your suggestions!!

Thanks


Copied from here

ShabbyX commented 8 years ago

@mrudulachougule

1) Apparently in the past they used to be two separate things. Now they are the same 2) Are you talking about rtai_lxrt.so? I don't know, maybe you had strict inlining so all the functions were inlined from the headers? 3) Do you mean rtai_lxrt.ko? It depends on rtai_hal.ko, so there is no way around that. If you want to insmod the modules on your own, there is nothing stopping you. 4) In python you import rtai_lxrt.so. The import would work regardless of whether rtai_lxrt.ko is inserted. That is, you would get the RTAI functions. Of course, if you try to call them without actually having inserted the RTAI modules, you'll get a crash. 5) I'm not really clear what you mean. Did you know that RTAI has python bindings itself? See here. You probably just need to do import rtai or something like that. 6) If the config is not available, then there is no option to use anything else. What is your problem and why do you need that config? 7) rtai_lxrt.ko and rtai_sched.ko are the same. What do you think is their difference?

mrudulachougule commented 8 years ago

Thank you for having look at my queries. Appreciate!! Here is little bit explanation for queries: 1) You mean to say rtai_lxrt and rtai_sched are now same in rtai-4.1 version? 2) In rtai-4.1 case rtai_lxrt.ko is soft linke of rtai_sched.ko (rtai_lxrt.ko -> rtai_sched.ko) which is not the case in rtai-3.8 any reason? 3) Since rtai_sched is getting inserted by default, when i try to insert rtai_lxrt is not allowing to insert. it says file already exists. any idea why? 4) How to import rtai_lxrt.so in python? Since I have inserted rtai_sched and not rtai_lxrt. I am not able to link with python code when running my application with python-3. 5) I am porting my code from python-2 to python-3 any idea on python-3 and rtai-4.1 how to bind so i can resolve dependencies? I am able to run my application code with python-2. Since i want to have to python-3. as python-2 support will be getting dropped soon. Please share you have any idea on changes needs to be done for rtai-4.1 to work with python-3. 6) CONFIG_RTAI_LXRT_USE_LINUX_SYSCALL option is not available to configure in rtai-4.1 where in same option is available in rtai-3.8 code. This option allows syscall to work with rtai calls when rtai is running in user space. 7)Yes. Both rtai_lxrt.ko and rtai_sched.ko are the same. Both are scheduler. But there is difference: rtai_lxrt is user space scheduler module where as rtai_sched is kernel space scheduler. They do differ in their execution respective properties. I having my application for rtai-3.8, python-2 working well on Ubuntu-10.04. I am porting my application for rtai-4.1, python-3 on Ubunut-14.04 and not able to run it as there are some changes observed in rtai-4.1 source code where in i am not able to insert the rtai_lxrt module and when trying to insert explicitly, it's always insert rtai_sched. Any idea on modifications required for rtai-4.1 and python-3 which will work or help to resolve dependency Errors.

Please share your views. I'm Stuck!!

ShabbyX commented 8 years ago

1) I believe so. And as you have seen, one is a symlink to the other. 2) I am not sure, but it seems to have to do with the internals of RTAI. I think it used to be possible to make a kernel thread real-time and back (like it is possible in user-space), but it's not anymore because no one was using it. Something along that line. 3) They are the same module, so of course you can't insert it twice. There is no point in trying to insert rtai_lxrt.ko instead of rtai_sched.ko when they are literally the same thing. 4) rtai_lxrt.ko has little to do with rtai_lxrt.so. If you have rtai_sched.ko (which is the same as rtai_lxrt.ko), you should be able to use rtai_lxrt.so either way. Like I said, RTAI already has a python interface that loads rtai_lxrt.so. You can see the code here. 5) there is no change as far as I know. RTAI doesn't compile the python files, so they are installed in $(prefix)/rtai-py. You just need to make sure that directory is known to python and just do import rtai. 6) Please explain more. Unless you do something specifically with system calls yourself, there should be no problem. RTAI itself takes care of communication between user and kernel spaces. 7) No. Both of them can schedule both user and kernel threads, even when they were two separate modules. Have you actually tried this? I remember (at least with RTAI 3.9) that I had issues with rtai_lxrt.ko and I just inserted rtai_sched.ko instead and everything was working ok (I had tens of kernel and user threads).

Please be more specific. What errors do you get? Like I said, you shouldn't have a problem with rtai_sched.ko inserted.

mrudulachougule commented 8 years ago

Appreciate your suggestions and views.

Here are few redefined queries:

1) If we have rtai_sched.ko inserted and rtai_lxrt loaded using dll method, will it affect the execution time or context switching latency? 2) In rtai-3.8 source code i have rtai_lxrt.ko which is getting inserted and it's not linked to rtai_sched.ko. So can I go ahead with rtai-4.1 which has rtai_lxrt.ko as link of rtai_sched.ko. and always getting inserted as rtai_sched. 3) I have problem of importing rtai modules in my python code when i'm trying to run it with python-3. Any idea what could be missing? 4) rtai/debian/rules has python dependency rule where i mentioned dh rule to create dependencies for python-2 ( dh_python2 -i and dh_python2 -s ) and when we install python-rtai.deb all rtai python files are getting installed under /usr/lib/python2.7/dist-packages/ any idea on how / where to modify to make it work with python-3.

Please share steps / suggestions on porting rtai python bindings from python-2 to python-3.

Thank you.

On Thu, Nov 19, 2015 at 8:19 AM, Shahbaz Youssefi notifications@github.com wrote:

1) I believe so. And as you have seen, one is a symlink to the other. 2) I am not sure, but it seems to have to do with the internals of RTAI. I think it used to be possible to make a kernel thread real-time and back (like it is possible in user-space), but it's not anymore because no one was using it. Something along that line. 3) They are the same module, so of course you can't insert it twice. There is no point in trying to insert rtai_lxrt.ko instead of rtai_sched.ko when they are literally the same thing. 4) rtai_lxrt.ko has little to do with rtai_lxrt.so. If you have rtai_sched.ko (which is the same as rtai_lxrt.ko), you should be able to use rtai_lxrt.so either way. Like I said, RTAI already has a python interface that loads rtai_lxrt.so. You can see the code here https://github.com/ShabbyX/RTAI/blob/master/rtai-py/rtai.py. 5) there is no change as far as I know. RTAI doesn't compile the python files, so they are installed https://github.com/ShabbyX/RTAI/blob/master/rtai-py/GNUmakefile.am in $(prefix)/rtai-py. You just need to make sure that directory is known to python and just do import rtai. 6) Please explain more. Unless you do something specifically with system calls yourself, there should be no problem. RTAI itself takes care of communication between user and kernel spaces. 7) No. Both of them can schedule both user and kernel threads, even when they were two separate modules. Have you actually tried this? I remember (at least with RTAI 3.9) that I had issues with rtai_lxrt.ko and I just inserted rtai_sched.ko instead and everything was working ok (I had tens of kernel and user threads).

Please be more specific. What errors do you get? Like I said, you shouldn't have a problem with rtai_sched.ko inserted.

— Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-158070690.

ShabbyX commented 8 years ago

No problem.

1) Everything should be ok in such a case. 2) Yes, just insert rtai_sched.ko and all is well. 3) You need to be more specific. You don't ask a doctor for cure by saying "I hurt", do you? 4) I'm not sure. Perhaps @zultron could help you when it comes to the Debian package. Maybe just change python2 to python3 and see what happens?

mrudulachougule commented 8 years ago

I apologise for the point (3). I should have explained a little bit.

So here is explanation on point 3:

I have rtai-4.1 source code. Since I want to create debian for rtai-4.1 and debian folder is not available for rtai-4.1 source code so i have copied debian folder from rtai-3.8 to rtai-4.1. source code. Able to build debian for rtai-4.1. Now I am porting my application code of python from python-2 to python-3. Since my rta-4.1 code is compiled with python-2 dependencies, i'm not able to import rtai modules in pyhton-3 code. Any idea on how to modify python dependencies for rta-4.1 so that it will create dependencies for python-3 and python bindings will be created properly?

Please share your views. I'm stuck!! :(

Thanks

On Thu, Nov 19, 2015 at 10:47 AM, Shahbaz Youssefi <notifications@github.com

wrote:

No problem.

1) Everything should be ok in such a case. 2) Yes, just insert rtai_sched.ko and all is well. 3) You need to be more specific. You don't ask a doctor for cure by saying "I hurt", do you? 4) I'm not sure. Perhaps @zultron https://github.com/zultron could help you when it comes to the Debian package. Maybe just change python2 to python3 and see what happens?

— Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-158115037.

mrudulachougule commented 8 years ago

Quick observation on point (4) I have modified rule from python2 to python3. I have two rules for installation and dependencies: dh_python3 -i and dh_python3 -s.

I am getting below Error message: dh_python3 tools:93: fix_shebang (debian/librtai-dev/usr/bin/rtai-config): doesn't look like a shebang: #! /bin/sh

Any idea what is still missing?

Thanks, Mrudula

On Thu, Nov 19, 2015 at 11:15 AM, Mrudula Chougule < chougulemrudula@gmail.com> wrote:

I apologise for the point (3). I should have explained a little bit.

So here is explanation on point 3:

I have rtai-4.1 source code. Since I want to create debian for rtai-4.1 and debian folder is not available for rtai-4.1 source code so i have copied debian folder from rtai-3.8 to rtai-4.1. source code. Able to build debian for rtai-4.1. Now I am porting my application code of python from python-2 to python-3. Since my rta-4.1 code is compiled with python-2 dependencies, i'm not able to import rtai modules in pyhton-3 code. Any idea on how to modify python dependencies for rta-4.1 so that it will create dependencies for python-3 and python bindings will be created properly?

Please share your views. I'm stuck!! :(

Thanks

On Thu, Nov 19, 2015 at 10:47 AM, Shahbaz Youssefi < notifications@github.com> wrote:

No problem.

1) Everything should be ok in such a case. 2) Yes, just insert rtai_sched.ko and all is well. 3) You need to be more specific. You don't ask a doctor for cure by saying "I hurt", do you? 4) I'm not sure. Perhaps @zultron https://github.com/zultron could help you when it comes to the Debian package. Maybe just change python2 to python3 and see what happens?

— Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-158115037.

ShabbyX commented 8 years ago

I see. Like I said, I don't know about debian, so @zultron may be able to help you.

#! /bin/sh is a shebang, so perhaps dh_python3 has a problem.

mrudulachougule commented 8 years ago

I am not able to post @zultron. https://github.com/zultron

Any guess what could be fix for above problem?

Kindly share details to post query @zultron. https://github.com/zultron

Thanks, Mrudula

On Thu, Nov 19, 2015 at 1:00 PM, Shahbaz Youssefi notifications@github.com wrote:

I see. Like I said, I don't know about debian, so @zultron https://github.com/zultron may be able to help you.

! /bin/sh is a shebang, so perhaps dh_python3 has a problem.

— Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-158157873.

mrudulachougule commented 8 years ago

Hi,

I am working on RTAI - 4.1 version. I am testing my application having multiple threads with rtai-4.1. I am getting Segmentation Fault and my application is crashing. Posting Call Trace:

LXRT CHANGED MODE (SYSCALL), PID = 1145, SYSCALL = 192. [ 35.033188] igb: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX [ 35.033333] igb 0000:05:00.0 eth0: Link Speed was downgraded by SmartSpeed [ 35.033467] IPv6: ADDRCONF(NETDEVCHANGE): eth0: link becomes ready [ 71.731741] watchraw[1190]: segfault at b70c2ffc ip b7376663 sp b70c3000 error 6 in libc-2.19.so http://libc-2.19.so[b7302000+1a8000] [ 71.731811] LXRT releases PID 1116 (ID: watch_raw). [ 71.731838] LXRT releases PID 1145 (ID: watch_raw). [ 71.731861] LXRT releases PID 1146 (ID: watch_raw). [ 71.731884] LXRT releases PID 1153 (ID: watch_raw). [ 71.731910] LXRT releases PID 1183 (ID: watch_raw). [ 71.731934] LXRT releases PID 1184 (ID: watch_raw). [ 71.731964] LXRT releases PID 1190 (ID: watchraw). [ 72.511946] BUG: Unhandled exception over domain RTAI at 0xf973615e - switching to ROOT_ [ 72.511953] CPU: 0 PID: 1065 Comm: vcontrol Tainted: G O 3.14.33-atom-rtai #1 [ 72.511957] Hardware name: ADLINK Technology Inc. ETX-BT/To be filled by O.E.M., BIOS 1.11 05/07/2015 [ 72.511959] 00000000 e9ca5e8c e9ca5e50 c04d24a4 e9ca5e84 c011a193 c0642b43 f9447e02 [ 72.511967] f973615e 00000000 0000000c f9448380 0000000e 00f3a000 00000000 00000000 [ 72.511973] 0000000e e9ca5edc c04d5925 00000000 00000000 f94f9d00 00000000 f95120a4 [ 72.511980] Call Trace: [ 72.511983] [] dump_stack+0x16/0x18 [ 72.511986] [] ipipe_handle_exception+0x141/0x18c [ 72.511989] [] ? rt_sem_wait+0x16/0x1bb [rtai_sem] [ 72.511992] [] error_code+0x5d/0x6c [ 72.511996] [] ? rt_sem_wait+0x16/0x1bb [rtai_sem] [ 72.511999] [] rt_schedule_soft+0xbc/0xdb [rtai_sched] [ 72.512002] [] lxrt_fun_call+0x6a/0x72 [rtai_sched] [ 72.512005] [] handle_lxrt_request+0x2fb/0x96a [rtai_sched] [ 72.512008] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem] [ 72.512011] [] ? SyS_stat64+0x28/0x2e [ 72.512015] [] rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 72.512018] [] ? rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 72.512021] [] lxrt_intercept_syscall+0x27/0xdf [rtai_sched] [ 72.512024] [] ipipe_notify_kevent+0x14/0x16 [ 72.512027] [] __ipipe_notify_syscall+0x14/0x16 [ 72.512030] [] pipeline_sysenter+0x7/0x1e [ 72.512033] [] ? no_context+0x35/0x16e [ 72.512043] BUG: unable to handle kernel NULL pointer dereference at 0000000c [ 72.512190] IP: [] rt_sem_wait+0x16/0x1bb [rtai_sem] [ 72.512312] *pde = 00000000 [ 72.512369] Oops: 0000 [#1] [ 72.512426] Modules linked in: rtai_shm(O) rtai_serial(O) rtai_mq(O) rtai_bits(O) rtai_tbx(O) rtai_fifos(O) rtai_msg(O) rtai_mbx(O) rtai_sem(O) rtai_sched(O) rtai_hal(O) xts gf128mul dm_crypt xt_REDIRECT xt_tcpudp iptable_mangle iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_filter ip_tables x_tables ppdev coretemp serio_raw joydev parport_pc iosf_mbi lp parport nls_iso8859_1 nls_cp437 vfat fat hid_generic usbhid hid crc32c_intel fbcon bitblit softcursor font psmouse tileblit i915 igb dca ptp pps_core i2c_algo_bit drm_kms_helper pata_marvell sdhci_pci sdhci led_class drm intel_gtt agpgart video button [ 72.513642] CPU: 0 PID: 1065 Comm: vcontrol Tainted: G O 3.14.33-atom-rtai #1 [ 72.513799] Hardware name: ADLINK Technology Inc. ETX-BT/To be filled by O.E.M., BIOS 1.11 05/07/2015 [ 72.513980] task: f4c6c4d0 ti: e9ca4000 task.ti: e9ca4000 [ 72.514086] EIP: 0060:[] EFLAGS: 00213292 CPU: 0 [ 72.514198] EIP is at rt_sem_wait+0x16/0x1bb [rtai_sem] [ 72.514301] EAX: 0000ffff EBX: 00000000 ECX: 00000000 EDX: f94f9d00 [ 72.514424] ESI: 00000000 EDI: f95120a4 EBP: e9ca5edc ESP: e9ca5ec8 [ 72.514547] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 0068 [ 72.514653] CR0: 80050033 CR2: 0000000c CR3: 35c1a000 CR4: 001007d0 [ 72.514775] I-pipe domain Linux [ 72.514836] Stack: [ 72.514875] bfac0d10 f4c6c4d0 f9511a20 00000000 f95120a4 e9ca5f10 f94f2554 00000000 [ 72.515037] b4288518 00000002 00000000 00000238 00000008 00090011 0000313c 00000efc [ 72.515205] f9511a20 bfac0c40 e9ca5f24 f94f366c bfac0c3c f94f9380 f9511a20 e9ca5f70 [ 72.515368] Call Trace: [ 72.515432] [] rt_schedule_soft+0xbc/0xdb [rtai_sched] [ 72.515566] [] lxrt_fun_call+0x6a/0x72 [rtai_sched] [ 72.515694] [] handle_lxrt_request+0x2fb/0x96a [rtai_sched] [ 72.515827] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem] [ 72.515954] [] ? SyS_stat64+0x28/0x2e [ 72.516058] [] rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 72.516189] [] ? rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 72.516323] [] lxrt_intercept_syscall+0x27/0xdf [rtai_sched] [ 72.516456] [] ipipe_notify_kevent+0x14/0x16 [ 72.516564] [] ipipe_notify_syscall+0x14/0x16 [ 72.516674] [] pipeline_sysenter+0x7/0x1e [ 72.516774] [] ? no_context+0x35/0x16e [ 72.516866] Code: e8 bc 06 dc ff eb 05 bb ff ff 00 00 8d 65 f8 89 d8 5b 5e 5d c3 55 89 e5 57 56 53 83 ec 08 3e 8d 74 26 00 b8 ff ff 00 00 8b 5d 08

<81> 7b 0c bb 3e f8 03 0f 85 91 01 00 00 e8 90 ee ff ff 8b 3d f0 [ 72.517338] EIP: [] rt_sem_wait+0x16/0x1bb [rtai_sem] SS:ESP 0068:e9ca5ec8 [ 72.517497] CR2: 000000000000000c [ 72.537982] ---[ end trace 4048cfbd517ece15 ]--- Kindly let me know if you have any information on the above errors, will be > helpful to debug! Thanks, Mrudula
ShabbyX commented 8 years ago

The first thing you should pay attention to is this:

LXRT CHANGED MODE (SYSCALL), PID = 1145, SYSCALL = 192.

This means that you called a Linux system call from a realtime thread. This means your thread is not realtime anymore.

Your bug seems to originate from this:

[ 72.512008] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem]

There are many reasons why this could crash. One is if you haven't initialized the thread (which could also be your main() thread) with RTAI. Another reason is if you are trying to delete a synchronization lock that is either not initialized or is NULL.

mrudulachougule commented 8 years ago

Thank you for looking into an issue. I would like to explain few debugging methods which i have followed.

1) I have rtai thread initialized and i'm calling gethostbyname( ) function inside rtai thread.

Results: rtai thread is getting stuck and system is crashing.

ERROR:

2) i have a pthread initialized and joined properly and i'm calling gethostbyname( ) function inside pthread.

Results: Thread working fine.

On Wed, Apr 13, 2016 at 7:10 PM, Shahbaz Youssefi notifications@github.com wrote:

The first thing you should pay attention to is this:

LXRT CHANGED MODE (SYSCALL), PID = 1145, SYSCALL = 192.

This means that you called a Linux system call from a realtime thread. This means your thread is not realtime anymore.

Your bug seems to originate from this:

[ 72.512008] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem]

There are many reasons why this could crash. One is if you haven't initialized the thread (which could also be your main() thread) with RTAI. Another reason is if you are trying to delete a synchronization lock that is either not initialized or is NULL.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-209444937

mrudulachougule commented 8 years ago

Thank you for looking into an issue. I would like to explain few debugging methods which i have followed. I have created small testing stuff to test out one function call separately. As far debugging i have observed that the function call gethostbyname() is the cause of this issue but not sure on this. Kindly take look at below steps and revert with your views which will be helpful for further debugging.

1) I have rtai thread initialized and i'm calling gethostbyname( ) function inside rtai thread.

Results: rtai thread is getting stuck and system is crashing.
ERROR:
*rt_test[3099]: segfault at b7719ffc ip b74a625b sp b771a000 error 6 in

libc-2.19.so http://libc-2.19.so[b7436000+1a8000]*

2) i have a pthread initialized and joined properly and i'm calling gethostbyname( ) function inside pthread.

Results: Thread working fine.

Attaching sample programs. Kindly have a look and let me know your suggestions or feedback.

Thanks, Mrudula

On Thu, Apr 14, 2016 at 4:04 PM, Mrudula Chougule <chougulemrudula@gmail.com

wrote:

Thank you for looking into an issue. I would like to explain few debugging methods which i have followed.

1) I have rtai thread initialized and i'm calling gethostbyname( ) function inside rtai thread.

Results: rtai thread is getting stuck and system is crashing.

ERROR:

2) i have a pthread initialized and joined properly and i'm calling gethostbyname( ) function inside pthread.

Results: Thread working fine.

On Wed, Apr 13, 2016 at 7:10 PM, Shahbaz Youssefi < notifications@github.com> wrote:

The first thing you should pay attention to is this:

LXRT CHANGED MODE (SYSCALL), PID = 1145, SYSCALL = 192.

This means that you called a Linux system call from a realtime thread. This means your thread is not realtime anymore.

Your bug seems to originate from this:

[ 72.512008] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem]

There are many reasons why this could crash. One is if you haven't initialized the thread (which could also be your main() thread) with RTAI. Another reason is if you are trying to delete a synchronization lock that is either not initialized or is NULL.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-209444937

ShabbyX commented 8 years ago

Let me emphasize again. You should never call a Linux system call from a realtime thread.

mrudulachougule commented 8 years ago

Yes. I got your point. I have few observations:

  1. The sample code which i shared in last mail compiled with RTAI 3.8.1 is working fine on ubuntu 10.04. Linux Version - 2.6.32-28-generic
    • RTAI version - 3.8.1*
    • The same code compiled with RTAI 4.1.1 is not working on ubuntu 14.04.
    • Linux Version - 3.13.0-79-generic*
    • RTAI version - 4.1.1*

Recently we upgraded our operating system from Ubuntu 10.04 to 14.04 version and RTAI from 3.8.1 to 4.1.1. The application using gethostbyname is working fine on Ubuntu 10.04. We need to have gethostbyname() function call in rtai thread, without this the functionality will not work. Kindly let me know how can i use gethostbyname() function call rtai thread or if is there any other method which can be used instead of gethostbyname() function call.

Kindly provide your suggestions/feedback.

Please do the needful.

Thanks, Mrudula

On Thu, Apr 14, 2016 at 5:52 PM, Shahbaz Youssefi notifications@github.com wrote:

Let me emphasize again. You should never call a Linux system call from a realtime thread.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-209912278

ShabbyX commented 8 years ago

If it ever worked, it had been by chance. You were likely not realtime back then either, but perhaps didn't notice it because Linux is already quite good in terms of latency.

If you need to have a Linux system call in each period of your task, you cannot run that task in realtime. There is no way around this. The Linux kernel is scheduled as a non-realtime thread by RTAI and there is absolutely no guarantees that it would return within your realtime task's deadline.

That is the case if you need to call gethostbyname() periodically in realtime (which is as I said, impossible). If you need to call it only once to get some information, or just occasionally, do it in a non-realtime normal posix thread.

mrudulachougule commented 8 years ago

Hey Thank you very much for detail information. I understood your explanation. The sample program which i have shared with you is having periodic function call of gethostbyname(), which will not be the case in our actual application. In the Actual Application I'm calling gethostbyname() only once to get host information which is part of rtai thread. So as you said because of this system call thread will become non real-time which is Okay. But I'm getting Segmentation Fault. Kindly have a look at the Error Log below:

[ 3.020076] hidraw: raw HID events driver (C) Jiri Kosina [ 3.024942] usbcore: registered new interface driver usbhid [ 3.024944] usbhid: USB HID core driver [ 3.026505] input: Hampshire Company TSHARC Analog Resistive as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.1/1-1.1:1.0/0003:07DD:0001.0001/input/input6 [ 3.027271] hid-generic 0003:07DD:0001.0001: input,hidraw0: USB HID v1.01 Mouse [Hampshire Company TSHARC Analog Resistive] on usb-0000:00:1d.0-1.1/input0 [ 3.268289] Console: switching to colour frame buffer device 128x48 [ 3.278668] i915 0000:00:02.0: fb0: inteldrmfb frame buffer device [ 3.278673] i915 0000:00:02.0: registered panic notifier [ 3.280535] ACPI: Video Device [GFX0](multi-head: yes rom: no post: no) [ 3.281364] acpi device:0a: registered as cooling_device0 [ 3.281519] input: Video Bus as /devices/LNXSYSTM:00/device:00/PNP0A08:00/LNXVIDEO:00/input/input7 [ 3.282994] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0 [ 3.585014] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. [ 3.826765] [drm] Enabling RC6 states: RC6 off, RC6p off, RC6pp off [ 3.874030] aufs test_add:305:busybox[156]: uid/gid/perm /sfs 0/0/0777, 0/0/01777 [ 4.007047] Switched to clocksource tsc [ 4.392776] init: ureadahead main process (183) terminated with status 5 [ 5.904768] usb 1-1.1: USB disconnect, device number 3 [ 6.102208] usb 1-1.1: new low-speed USB device number 4 using ehci-pci [ 6.212132] input: Hampshire Company TSHARC Analog Resistive as /devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.1/1-1.1:1.0/0003:07DD:0001.0002/input/input8 [ 6.212328] hid-generic 0003:07DD:0001.0002: input,hidraw0: USB HID v1.01 Mouse [Hampshire Company TSHARC Analog Resistive] on usb-0000:00:1d.0-1.1/input0 [ 6.319038] systemd-udevd[335]: starting version 204 [ 6.841852] lp: driver loaded but no devices found [ 6.989365] parport_pc 00:05: reported by Plug and Play ACPI [ 6.989420] parport0: PC-style at 0x378, irq 5 [PCSPP] [ 7.083628] lp0: using parport0 (interrupt-driven). [ 7.848702] ppdev: user-space parallel port driver [ 9.317533] ip_tables: (C) 2000-2006 Netfilter Core Team [ 9.391143] nf_conntrack version 0.5.0 (16384 buckets, 65536 max) [ 9.986637] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 10.771705] init: failsafe main process (538) killed by TERM signal [ 13.810566] init: plymouth-upstart-bridge main process ended, respawning [ 13.883336] init: plymouth-upstart-bridge main process (818) terminated with status 1 [ 13.883374] init: plymouth-upstart-bridge main process ended, respawning [ 14.082291] bio: create slab at 1 [ 14.680857] init: plymouth-stop pre-start process (881) terminated with status 1 [ 15.503641] I-pipe: head domain RTAI registered. [ 15.503651] RTAI[hal]: compiled with gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) . [ 15.503659] RTAI[hal]: mounted (IPIPE-NOTHREADS, IMMEDIATE (INTERNAL IRQs DISPATCHED), ISOL_CPUS_MASK: 0). [ 15.503664] SYSINFO: CPUs 1, LINUX APIC IRQ 0, TIM_FREQ 1193182, CLK_FREQ 1747200000, CPU_FREQ 1747200000 [ 15.573744] RTAI[malloc]: global heap size = 2097152 bytes, . [ 15.574783] , kstacks pool size = 524288 bytes. [ 15.574787] RTAI[sched]: hard timer type/freq = 8254-PIT/1193180(Hz); default timing: periodic; linear timed lists. [ 15.574792] RTAI[sched]: Linux timer freq = 250 (Hz), TimeBase freq = 1747200000 hz. [ 15.574795] RTAI[sched]: timer setup = 5035 ns, resched latency = 0 ns.

[ 16.071273] TTY_INDX: 0, PORT: 3f8, IRQ 4. [ 16.071280] # OF PORTS: 1, BUFFER SIZE: 512. [ 24.836749] [ 24.836749] LXRT CHANGED MODE (SYSCALL), PID = 1144, SYSCALL = 192. [ 35.381705] igb: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX [ 35.381834] igb 0000:05:00.0 eth0: Link Speed was downgraded by SmartSpeed [ 35.381967] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready [ 385.961809] LXRT releases PID 1063 (ID: vcontrol). [ 385.997734] LXRT releases PID 1115 (ID: watch_raw). [ 385.997785] LXRT releases PID 1144 (ID: watch_raw). [ 385.997826] LXRT releases PID 1145 (ID: watch_raw). [ 385.997863] LXRT releases PID 1156 (ID: watch_raw). [ 385.997902] LXRT releases PID 1182 (ID: watch_raw). [ 385.997939] LXRT releases PID 1183 (ID: watch_raw). [ 514.842633] LOADING >>>> /home/vilter/vcontrol/csv/VSS451R7.csv [ 533.095724] Running Modbus TCP server... [ 542.265050] Creating Sequencing thread [ 542.773704] LOADING >>>> /home/vilter/vcontrol/csv/VSS451R7.csv [ 574.858451] 3::In fillAddr [ 574.858490] watchraw[1856]: segfault at b7158ffc ip b740c663 sp b7159000 error 6 in libc-2.19.so http://libc-2.19.so[b7398000+1a8000] [ 574.858561] LXRT releases PID 1829 (ID: watch_raw). [ 574.858587] LXRT releases PID 1836 (ID: watch_raw). [ 574.858611] LXRT releases PID 1837 (ID: watch_raw). [ 574.858633] LXRT releases PID 1842 (ID: watch_raw). [ 574.858660] LXRT releases PID 1852 (ID: watch_raw). [ 574.858685] LXRT releases PID 1857 (ID: watch_raw). [ 574.858709] LXRT releases PID 1853 (ID: watch_raw). [ 574.896998] LXRT releases PID 1856 (ID: watch_raw). [ 574.919653] BUG: Unhandled exception over domain RTAI at 0xf973115e - switching to ROOT [ 574.919661] CPU: 0 PID: 1794 Comm: vcontrol Tainted: G O 3.14.33-atom-rtai #1 [ 574.919664] Hardware name: ADLINK Technology Inc. ETX-BT/To be filled by O.E.M., BIOS 1.11 05/07/2015 [ 574.919667] 00000000 c0091e8c c0091e50 c04d24a4 c0091e84 c011a193 c0642b43 f9442e02 [ 574.919674] f973115e 00000000 0000000c f9443380 0000000e 00d8a000 00000000 00000000 [ 574.919681] 0000000e c0091edc c04d5925 00000000 00000000 f94f4d00 00000000 f95100a4 [ 574.919687] Call Trace: [ 574.919691] [] dump_stack+0x16/0x18 [ 574.919694] [] ipipe_handle_exception+0x141/0x18c [ 574.919697] [] ? rt_sem_wait+0x16/0x1bb [rtai_sem] [ 574.919700] [] error_code+0x5d/0x6c [ 574.919703] [] ? rt_sem_wait+0x16/0x1bb [rtai_sem] [ 574.919707] [] rt_schedule_soft+0xbc/0xdb [rtai_sched] [ 574.919710] [] lxrt_fun_call+0x6a/0x72 [rtai_sched] [ 574.919713] [] handle_lxrt_request+0x2fb/0x96a [rtai_sched] [ 574.919716] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem] [ 574.919719] [] ? SyS_stat64+0x28/0x2e [ 574.919723] [] rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 574.919726] [] ? rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 574.919729] [] lxrt_intercept_syscall+0x27/0xdf [rtai_sched] [ 574.919732] [] ipipe_notify_kevent+0x14/0x16 [ 574.919735] [] __ipipe_notify_syscall+0x14/0x16 [ 574.919739] [] pipeline_sysenter+0x7/0x1e [ 574.919742] [] ? no_context+0xb0/0x16e [ 574.919751] BUG: unable to handle kernel NULL pointer dereference at 0000000c [ 574.919900] IP: [] rt_sem_wait+0x16/0x1bb [rtai_sem] [ 574.920021] *pde = 00000000 [ 574.920078] Oops: 0000 [#1] [ 574.920135] Modules linked in: rtai_shm(O) rtai_serial(O) rtai_mq(O) rtai_bits(O) rtai_tbx(O) rtai_fifos(O) rtai_msg(O) rtai_mbx(O) rtai_sem(O) rtai_sched(O) rtai_hal(O) xts gf128mul dm_crypt xt_REDIRECT xt_tcpudp iptable_mangle iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_filter ip_tables x_tables ppdev joydev coretemp serio_raw parport_pc iosf_mbi lp parport nls_iso8859_1 nls_cp437 vfat fat hid_generic usbhid hid crc32c_intel fbcon bitblit softcursor psmouse font igb dca ptp tileblit i915 pps_core i2c_algo_bit drm_kms_helper pata_marvell sdhci_pci sdhci led_class drm intel_gtt agpgart video button [ 574.921355] CPU: 0 PID: 1794 Comm: vcontrol Tainted: G O 3.14.33-atom-rtai #1 [ 574.921512] Hardware name: ADLINK Technology Inc. ETX-BT/To be filled by O.E.M., BIOS 1.11 05/07/2015 [ 574.921692] task: ea0d6f20 ti: c0090000 task.ti: c0090000 [ 574.921799] EIP: 0060:[] EFLAGS: 00213292 CPU: 0 [ 574.921911] EIP is at rt_sem_wait+0x16/0x1bb [rtai_sem] [ 574.922013] EAX: 0000ffff EBX: 00000000 ECX: 00000000 EDX: f94f4d00 [ 574.922136] ESI: 00000000 EDI: f95100a4 EBP: c0091edc ESP: c0091ec8 [ 574.922259] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 0068 [ 574.922365] CR0: 80050033 CR2: 0000000c CR3: 2a10c000 CR4: 001007d0 [ 574.922488] I-pipe domain Linux [ 574.922548] Stack: [ 574.922587] bff9f630 ea0d6f20 f950fa20 00000000 f95100a4 c0091f10 f94ed554 00000000 [ 574.922750] aff73bd8 00000002 00000000 00001a01 00001c38 00000201 00001c60 00001a01 [ 574.922912] f950fa20 bff9f560 c0091f24 f94ee66c bff9f55c f94f4380 f950fa20 c0091f70 [ 574.923074] Call Trace: [ 574.923138] [] rt_schedule_soft+0xbc/0xdb [rtai_sched] [ 574.923272] [] lxrt_fun_call+0x6a/0x72 [rtai_sched] [ 574.923400] [] handle_lxrt_request+0x2fb/0x96a [rtai_sched] [ 574.923533] [] ? rt_named_rwl_delete+0x43/0x43 [rtai_sem] [ 574.923660] [] ? SyS_stat64+0x28/0x2e [ 574.923764] [] rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 574.923895] [] ? rtai_lxrt_invoke+0x33/0x53 [rtai_sched] [ 574.924030] [] lxrt_intercept_syscall+0x27/0xdf [rtai_sched] [ 574.924162] [] ipipe_notify_kevent+0x14/0x16 [ 574.924271] [] ipipe_notify_syscall+0x14/0x16 [ 574.924380] [] pipeline_sysenter+0x7/0x1e [ 574.924480] [] ? no_context+0xb0/0x16e [ 574.924572] Code: e8 bc 06 dc ff eb 05 bb ff ff 00 00 8d 65 f8 89 d8 5b 5e 5d c3 55 89 e5 57 56 53 83 ec 08 3e 8d 74 26 00 b8 ff ff 00 00 8b 5d 08

<81> 7b 0c bb 3e f8 03 0f 85 91 01 00 00 e8 90 ee ff ff 8b 3d f0 [ 574.925044] EIP: [] rt_sem_wait+0x16/0x1bb [rtai_sem] SS:ESP 0068:c0091ec8 [ 574.925203] CR2: 000000000000000c [ 574.945685] ---[ end trace 37ddfd9e8dd22d8e ]--- Kindly let me know if you have any idea on this. Appreciate your help. Thanks, Mrudula On Thu, Apr 14, 2016 at 7:00 PM, Shahbaz Youssefi notifications@github.com wrote: > If it ever worked, it had been by chance. You were likely not realtime > back then either, but perhaps didn't notice it because Linux is already > quite good in terms of latency. > > If you need to have a Linux system call in each period of your task, you > cannot run that task in realtime. There is no way around this. The Linux > kernel is scheduled as a non-realtime thread by RTAI and there is > absolutely no guarantees that it would return within your realtime task's > deadline. > > That is the case if you need to call gethostbyname() periodically in > realtime (which is as I said, impossible). If you need to call it only once > to get some information, or just occasionally, do it in a non-realtime > normal posix thread. > > — > You are receiving this because you were mentioned. > Reply to this email directly or view it on GitHub > https://github.com/ShabbyX/RTAI/issues/26#issuecomment-209941257
ShabbyX commented 8 years ago

I can't tell much without seeing code. I see the bug is a bad pointer given to rt_sem_wait. But whether you are calling that function or RTAI itself, I don't know.

I don't have an RTAI installation handy to try out your code (even if you provide it), so I'm afraid you need to debug this yourself. Have you tried going through the code with gdb and seeing where the crash happens? Or put some logs (rt_printk) and try to identify the line that causes the crash?

mrudulachougule commented 8 years ago

I understand your point. Appreciate for sharing your views.

I have tried to debug this issue using gdb core file. Since i am calling gethostbyname() function in application code. From back trace log, I'm able to see pointer is pointing to mallloc_init function which is standered from libc6 --> malloc.c file.

One more observation if I comment out gethostbyname() function in application code. Application works fine without getting hang. Threads are also running and not able to see segmentation fault.

I suspect there is problem with gethostbyname() function being called in RTAI thread. But I'm not able to understand why it is giving segmentation fault.

Kindly share your views or suggestions.

I would like to understand root cause of this problems.

Your feedback is highly appreciated!

Thanks, Mrudula

On Fri, Apr 15, 2016 at 1:34 AM, Shahbaz Youssefi notifications@github.com wrote:

I can't tell much without seeing code. I see the bug is a bad pointer given to rt_sem_wait. But whether you are calling that function or RTAI itself, I don't know.

I don't have an RTAI installation handy to try out your code (even if you provide it), so I'm afraid you need to debug this yourself. Have you tried going through the code with gdb and seeing where the crash happens? Or put some logs (rt_printk) and try to identify the line that causes the crash?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-210126170

ShabbyX commented 8 years ago

I really don't know anymore at this point. Try asking this in the mailing list (rtai@rtai.org) and see if anyone has had issues with gethostbyname.

mrudulachougule commented 8 years ago

Hi,

I have started migrating kernel 3.14 on ARM Platform. I am currently working on BeagaleBone ARM Cortex A8 processor. Since I want to patch kernel with RTAI, looking for RTAI kernel patches for ARM Cortex -A8 architecture. Unable to find ARM Cortex A8 patches in RTAI 4.1 release. Even I have checked in latest RTAI release 5.0. Unable to find the same.

Kindly let me know if you have any idea / threads where i can look into for those patches.

Your suggestions / Feedback will be helpful.

Thanks, Mrudula

On Fri, Apr 15, 2016 at 6:48 PM, Shahbaz Youssefi notifications@github.com wrote:

I really don't know anymore at this point. Try asking this in the mailing list (rtai@rtai.org) and see if anyone has had issues with gethostbyname.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/ShabbyX/RTAI/issues/26#issuecomment-210461292

ShabbyX commented 8 years ago

@mrudulachougule I can't find any new information on that. It seems that ARM patches has been in "unstable" mode for years. You can always try asking the mailing list, rtai rtai [.] org.