Hi Olaf,

I know nothing about comedi, but plenty of fp experience.

Remember, a RT thread runs immediately after being created
(pthread_create()) so try to put your pthread_setfp_np into your
thread_code() just before while(1).

Note that kernel's sprintf does not support fp format.

Regards,

pa

On Wed, Sep 27, 2000 at 12:25:33PM +0200, Olaf Petzold wrote:
> Hello,
> 
> I want to use a thread for doing some fp ops. The thread is called by a callback 
> function (comedi_callback). The problem is, after the thread was created
> the system hangs. Why ? Who has experience (maybe with some code examples)
> with comedi callback?
> 
> Thanks        Olaf
> 
> Here are the code:
> 
> void *thread_code(void *param) 
> {
>     static size_t ctr = 0; 
>     static char buf[80];  
>     while(1) { 
> 
>         sprintf(buf, "%10d\n", ctr++); 
>         rtf_put(1, buf, 11);  
>         pthread_suspend_np(pthread_self()); 
>         rtl_printf("suspended pthread self\n");
>      }  
> 
>     return 0; 
> }                                                                             
>       
> int callback(unsigned int flags, void *arg)
> {
>     //pthread_wakeup_np(rt_thread);
>  
>     return 1;
> }   
> 
>     int init_module(void)
> {
>     int ret = 0;
>     pthread_attr_t attr;
>     struct sched_param sched_param;
>  
>     // install rtf
>     rtf_destroy(1);
>     ret = rtf_create(1, 4096);                                                       
>                                                                          
>    [...]
> 
>     // lock the subdevices
>     comedi_lock_ioctl(ai_dev,ai_subdev);
>     comedi_lock_ioctl(ao_dev,ao_subdev);
>  
>     // ... create the realtime task with the default function
>     pthread_attr_init(&attr);
>     //pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE);
>     //sched_param.sched_priority = 100;
>     //pthread_attr_setschedparam(&attr, &sched_param);
>  
>     rtl_printf("create thread\n");
>     if((ret = pthread_create(&rt_thread, &attr, thread_code, (void *)0)) != 0) {
>         rtl_printf("unable to create realtime thread (error %d) !\n", ret);
>     }
>  
>     rtl_printf("set FP on thread\n");
>     if((ret = pthread_setfp_np(rt_thread, 1)) != 0) {
>         rtl_printf("unable to use floating-point operations in realtime thread 
>(error %d) !\n",
>                    ret);
>     }                                                                                
>  
> #if 0
>     rtl_printf("register our callback function\n");
>     ret=comedi_register_callback(ai_dev, ai_subdev, COMEDI_CB_EOS, &callback, (void 
>*)0);
>  
>     /* start acq. */
>     ret=comedi_trig_ioctl(ai_dev,ai_subdev,&ai_trig);
> #endif                                                                          
> 
>     rtl_printf("comedi_callback module started\n");
>  
>     return 0;
> }
>  
> void cleanup_module(void)
> {
>     comedi_cancel_ioctl(ai_dev,ai_subdev);
>     comedi_unlock_ioctl(ai_dev,ai_subdev);
>     comedi_unlock_ioctl(ao_dev,ao_subdev);
>  
>     pthread_suspend_np(rt_thread);
>     pthread_setfp_np(rt_thread, 0);
>     pthread_delete_np(rt_thread);
>  
>     rtf_destroy(1);
>  
>     rtl_printf("comedi_callback stopped\n");
> }                                                                                    
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> ---
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/

-- 
..........................................................................
Pavel Andris                               | tel: +421 7 5941 2167
Institute of Control Theory and Robotics   | fax: +421 7 5477 6045
Slovak Academy of Sciences                 | 
Dubravska cesta 9                          | e-mail: [EMAIL PROTECTED]
SK - 842 37 Bratislava                     |
Slovakia                                   |
..........................................................................
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to