i have a problem with rtL pthread : the system freeze after n iterations
with n between 150 and 1200...

here is the offending code (it deal with the parallel port, used as a login input with
a IR Led sensor connected)

Cedric
-----

#include <rtl_fifo.h>
#include <rtl_core.h>
#include <rtl_time.h>
#include <rtl.h>
#include <pthread.h>
#include <asm/io.h>

#define LPT_PORT 0x378
#define LPT_CONTROL 0x37A
#define LPT_STATE 0x379

#define FIFO_BUF_LENGTH 4000
pthread_t look_ack;
long time_base=1000000000L;
int FIFO_NB=0;

void *watch_ack(void *param)
{
  unsigned char loading_mesg,loading_mesg_old=0;
  int time_length=0;
  struct sched_param p;
  p.sched_priority=1;
  pthread_setschedparam(pthread_self(),SCHED_FIFO,&p);
  pthread_make_periodic_np(pthread_self(),gethrtime(),10000L);
  while(1)
    {
      loading_mesg=inb(LPT_STATE);

      //      rtl_printf("Valeur %#x depuis %d\n", loading_mesg, time_length);
      loading_mesg&=0x40;
      if(loading_mesg!=loading_mesg_old)
        {
          rtl_printf("Changement : %#x\n",loading_mesg);
          rtf_put(FIFO_NB,&time_length,sizeof(time_length));
          time_length=0;
          loading_mesg_old=loading_mesg;
        }
      time_length++;
      pthread_wait_np();     
    }
}

int init_module(void)
{
  printk("Start executing....\n Please wait.... fifo %d taille %d periode %ld\n"
, FIFO_NB, FIFO_BUF_LENGTH, time_base);

  
  rtf_create(FIFO_NB,FIFO_BUF_LENGTH);
  
  pthread_create(&look_ack,NULL,watch_ack,NULL);
 
  return 0;
}

void cleanup_module(void)
{
  printk("Thanks for waiting\nBye.\n");
  pthread_delete_np(look_ack);
  rtf_destroy(FIFO_NB);
}
-- [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