Problem using rt_sem_wait

Suessmilch Bernd Bernd.Suessmilch at SWAROVSKI.COM
Mon Jan 23 13:33:17 CET 2006


> -----Original Message-----
> From: rtai-admin at rtai.org [mailto:rtai-admin at rtai.org]On 
> Behalf Of Jorge
> Almeida
> Sent: Montag, 23. Januar 2006 12:06
> To: rtai at rtai.org
> Subject: Problem using rt_sem_wait
> 
> 
> 
> 
> Hello to all.
> 
> I'm using rtai-3.3-test4 with a linux 2.6.14 kernel compiled 
> with GCC 3.3.4.
> 
> 
> I have a small apllication that uses two tasks. And to share 
> information 
> between them i use shared memories and semaphores.
> My problem is the following:
> When a wait for a semaphore in the main program (int main) it 
> works OK and the 
> information is passed to the shared memory. When i want to get the 
> information from the shared memory in another task i wait for 
> the semaphore 
> to be locked with rt_sem_wait (as i use in the main task to put the 
> information) and a message in /var/log/message appers with 
> the following:
> 
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Unable to handle 
> kernel NULL pointer 
> dereference at virtual address 000003f0
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  printing eip:
> Jan 23 10:51:57 Portatil-CRITICAL kernel: d4dd9ea6
> Jan 23 10:51:57 Portatil-CRITICAL kernel: *pde = 00000000
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Oops: 0000 [#6]
> Jan 23 10:51:57 Portatil-CRITICAL kernel: PREEMPT
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Modules linked in: 
> rtai_shm rtai_sem 
> rtai_lxrt rtai_hal usbserial parport_pc
> lp parport nvram speedstep_lib thermal processor fan button 
> battery ac 
> snd_pcm_oss snd_mixer_oss snd_maestro3
> snd_ac97_codec snd_ac97_bus snd_pcm snd_timer snd soundcore 
> snd_page_alloc 
> ipv6 edd af_packet binfmt_misc evdev sg st
> usbhid sd_mod sr_mod scsi_mod ide_cd cdrom uhci_hcd nls_utf8 
> ntfs intel_agp 
> agpgart i2c_piix4 i2c_core dm_mod 3c59x mii
> usbcore joydev reiserfs
> Jan 23 10:51:57 Portatil-CRITICAL kernel: CPU:    0
> Jan 23 10:51:57 Portatil-CRITICAL kernel: EIP:    
> 0060:[<d4dd9ea6>]    Not 
> tainted VLI
> Jan 23 10:51:57 Portatil-CRITICAL kernel: EFLAGS: 00013202   
> (2.6.14-rtai3.3)
> Jan 23 10:51:57 Portatil-CRITICAL kernel: EIP is at 
> rtai_lxrt_invoke+0xb6/0xfe0 [rtai_lxrt]
> Jan 23 10:51:57 Portatil-CRITICAL kernel: eax: 00000000   
> ebx: 0000002c   ecx: 
> c0428f80   edx: 00000000
> Jan 23 10:51:57 Portatil-CRITICAL kernel: esi: d4de6300   
> edi: 00000001   ebp: 
> 40daf614   esp: c1bb1ebc
> Jan 23 10:51:57 Portatil-CRITICAL kernel: ds: 007b   es: 007b 
>   ss: 0068
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Process test (pid: 13497, 
> threadinfo=c1bb0000 task=c0817030)
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Stack: d4ddf7c4 
> 0002c804 40daf614 
> 00000000 00000066 c6e0f934 00000000 00000001
> Jan 23 10:51:57 Portatil-CRITICAL kernel:        00000000 
> 00000001 c1bb1f14 
> c011ab5a c04386ec 00000003 00000001 00000000
> Jan 23 10:51:57 Portatil-CRITICAL kernel:        00000000 
> 00000003 c04386ec 
> 00000200 00000000 c1bb1fbc 70000000 00000021
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Call Trace:
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c011ab5a>] 
> __wake_up+0x9a/0xd0
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<d4dd8bfb>] 
> lxrt_intercept_syscall_prologue+0xfb/0x1f0 [rtai_lxrt]
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c0293110>] 
> write_chan+0x0/0x210
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c0176030>] 
> vfs_write+0x160/0x1c0
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c014d302>] 
> __ipipe_dispatch_event+0x32/0x170
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c017618e>] 
> sys_write+0x7e/0x80
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c0116cc5>] 
> __ipipe_syscall_root+0x25/0xc0
> Jan 23 10:51:57 Portatil-CRITICAL kernel:  [<c01035e2>] 
> sysenter_past_esp+0x3b/0x67
> Jan 23 10:51:57 Portatil-CRITICAL kernel: Code: 04 00 00 8b 
> 44 24 68 c1 e8 18 
> 83 e0 0f 8b 34 85 20 7e de d4 85 f6 0f 84
> dd 04 00 00 8b 3c de 85 ff 0f 84 ab 05 00 00 8b 54 24 50 <8b> 
> 82 f0 03 00 00 
> 85 c0 0f 88 f0 05 00 00 8b 4c 24 68 8b 5c
> de
> 
> 
> After some debugging in my application i see that any of my 
> pointers are NULL. 
> Then i start to debug RTAI code where the message tell me 
> (rtai_lxrt_invoke) 
> that is in the  /path-to-src/base/sched/sys.c file.
> I put some rt_printk in the code and the following appers:
> Jan 23 10:51:57 Portatil-CRITICAL kernel: JALMEIDA::task 
> =current->rtai_tskext 
> =00000000
> Jan 23 10:51:57 Portatil-CRITICAL kernel: 
> JALMEIDA::rtai_lxrt_invoke:before 
> handle_lxrt_request: lxsrq = 182276 arg = 40daf614      task 
> = 00000000
> 
> the task variable is NULL and that is the problem.
> 
> But why the task pointer is NULL????
> That is my question to all that can answer it.
I assume, that your apps is running in US.
Did you create a task buddy for the task that calls rt_sem_wait()?
I.e., did you ever call rt_task_init() or rt_task_init_schmod() inside
your thread function?

Best regards,
Bernd




More information about the Rtai mailing list