Scheduling priority in RTLinux!

Hi all,

I wants to test  priority for a card which is having FIFO on board. I kept three LED for checking it's flags(Half, Full and Empty), I starts transferring data when half flag occur.
So Logically Full flag should not occur, but if I fire some other events (like start Netscape) full flag LED glows.

I tried to solve it by setting scheduling in RTLinux. But didn't reflecting..
How do I set priority in my module, so when DMA transfer [read(.. )] should have highest priority?

What is missing in following code:

In Kernel Module:
int init_module(void)
{

        pthread_attr_t attr;
 struct sched_param sched_param;

 if (register_chrdev(HYTEC_MAJOR,"hytec",&hytec_fops)) {
  printk("hytec: unable to get major %d\n", HYTEC_MAJOR);
  return -EIO;
 }
 printk("Registered device hytec(new): major 60\n");

       //add


 rtf_destroy(0);
 rtf_destroy(1);
 rtf_destroy(2);
 rtf_destroy(3);
 rtf_destroy(4);


 rtf_create(0,4000);
 rtf_create(1,4000);
        rtf_create(2,4000);
        rtf_create(3,4000);
        rtf_create(4,4000);

 pthread_attr_init (&attr);
 sched_param.sched_priority=1;
 pthread_attr_setschedparam(&attr, &sched_param);

 pthread_create (&tasks[0], &attr, thread_code, (void *)0);

        pthread_attr_init (&attr);
 sched_param.sched_priority=2;
 pthread_attr_setschedparam(&attr, &sched_param);

 pthread_create (&tasks[1], &attr, thread_code, (void *)1);

 rtf_create_handler(0, &my_handler);

 return 0;
}

void *thread_code(void *t)
{
  int taskno=(int)t;
  int fifo= taskno+1;
  struct my_msg_struct msg;
  //msg.command=0;

  pthread_make_periodic_np(pthread_self(), gethrtime(), 500000000);

  while(1)
    {
      pthread_wait_np();
      //if (! rtf_isempty (fifo))
      rtf_get (fifo, &msg, sizeof(msg));

      switch(msg.command)
 {
 case 1:
   case 2:
// .........
break;
   return 0;


  }
  }
      return 0;
    }

// In User space Application

 ctl = open("/dev/rtf0", O_WRONLY);
 fd0 = open("/dev/rtf1", O_RDONLY);
 fd1 = open("/dev/rtf2", O_RDONLY);
         if(ctl  > 0)
      printf("CTL Driver opened %d\n", fp);
     else
   { printf("Not opening CTL.. /dev/rtf0 \n"); exit(1);
  }


    msg.task=0;
 msg.command=1;
 write(ctl, &msg, sizeof(msg));
    msg.task=1;
 msg.command=2;
 write(ctl, &msg, sizeof(msg));

 while (i<1000)
   {
     FD_ZERO(&rfds);
     FD_SET(fd0, &rfds);
     FD_SET(fd1, &rfds);
     tv.tv_sec=0;
     tv.tv_usec=250000;
     retval=select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
}
     swap++;
     i++;
     }
  }





-Mona.

Received on 2002-11-15Z21:58:00