Vidarte Ana ([EMAIL PROTECTED]) wrote:
> Hello,
> 
> Can someone send me an example of a real time application with a periodic
> task?

You need to use pthread_setfp_np(pthread_self(), 1) before
using any floating-point operations in an RT-thread.
Also, if Inicializa_modelo() and Finaliza_modelo() use FP-operations,
you need to move them in the thread code.

Michael.

> 
> I have try the following:
> 
> #include <rtl.h>
> #include <time.h>
> #include <pthread.h>
> #include <float.h>
> #include "modelo.h"
> 
> pthread_t thread;
> 
> void * start_routine(void *arg)
> {
>       float salida;
>       struct sched_param p;
>       p . sched_priority = 1;
>       pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
> 
>       pthread_make_periodic_np (pthread_self(), gethrtime(), 1000000);
> 
>       while (1) {
>               Actualiza modelo():
>               salida=Salida_modelo();
>               pthread_wait_np ();
>               rtl_printf("Salida %f\n", salida);
>       }
>       return 0;
> }
> 
> int init_module(void) {
>       Inicializa_modelo();
>       return pthread_create (&thread, NULL, start_routine, 0);
> }
> 
> void cleanup_module(void) {
>       Finaliza_modelo();
>       pthread_delete_np (thread);
> }
> 
> But, the system crashes.
> 
> Ana.
> --- [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/
--- [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