2011-04-14 11:55:47     Real time

Document created by Aaronwu Employee on Aug 26, 2013
Version 1Show Document
  • View in full screen mode

2011-04-14 11:55:47     Real time

Jean Nicollerat (SWITZERLAND)

Message: 99848   

 

Hi,

 

I have make an audio application. I need that my application have an hight priority.

 

I try to set with "sched_setscheduler" the priority 99 but when do that it's worst, I mesure 50ms of time out of my application.

 

What is the best way to make my audio application in high priority ?

 

regards

QuoteReplyEditDelete

 

 

2011-04-14 12:00:19     Re: Real time

Steve Strobel (UNITED STATES)

Message: 99849   

 

I am not familiar with sched_setscheduler, but at least with "nice", lower numbers (down to -20) represent higher priorities.

 

Steve

QuoteReplyEditDelete

 

 

2011-04-14 12:58:48     Real time

Jeremie RAFIN (FRANCE)

Message: 99851    This is from my notes:

 

/* Thread priority

* NOTE: the lower value, the lower priority.

* The kernel set the "kernel priority" to 99 - "[p|k]ThreadPriority" value

* For user land, the possible values are [1..79] (the kernel priority is [98..20])

* For kernel land, the possible values are [1..99] (the kernel priority is [98..0])

*/

 

So if your task is in the user land, value 99 is not possible; try 79.

You must also be root, of course.

 

Hope this can help you.

-j

QuoteReplyEditDelete

 

 

2011-04-14 13:56:44     Re: Real time

Mike Frysinger (UNITED STATES)

Message: 99855   

 

what is significantly more important is the schedule policy you used.  if you have no other real time threads in the system, then you should be able to simply use SCHED_FIFO or SCHED_RR and get higher priority than all other userspace processes.

QuoteReplyEditDelete

 

 

2011-04-15 04:48:14     Re: Real time

Jean Nicollerat (SWITZERLAND)

Message: 99881   

 

I have this code    :

 

sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO);

    if (!sched_setscheduler(0, SCHED_FIFO, &sched_param)) {

 

...

 

}

 

When I add this, I have overrun on the snd out handle, it seem that the cause is that the process is not running during more than 50 ms.

 

I calculate the time in the main process with gettimeofday(). Without the "sched_setscheduler" I have somthing like 100us but with the "sched_setscheduler" I calculate 50ms.

 

I try with priority 2, 20, and max there is the same probleme.

 

Any idee what hapend ? Do I  have to check for some options in the kernel compilation ?

 

 

 

regards

 

Jean

QuoteReplyEditDelete

 

 

2011-04-15 05:31:58     Re: Real time

Mike Frysinger (UNITED STATES)

Message: 99885   

 

yeah, i cant verify that behavior.  seems to work fine for me.  taking a process, using the snippet you posted, and then running while (1) gettimeofday(&tv, NULL) shows it running many times per microsecond.  even when launching processes in the background that do nothing but consume the cpu (like `top -d 0 > /dev/null`).

 

keep in mind that the tv_usec field of gettimeofday by default is locked to like 1 jiffie granularity.  this comes directly from CONFIG_HZ_# in the kernel.  if you want higher resolution, you probably need to select a higher resolution clock source in your kernel config.

QuoteReplyEditDelete

 

 

2011-04-15 10:24:22     Re: Real time

Jean Nicollerat (SWITZERLAND)

Message: 99889   

 

I try to change the change the CONFIG_HZ and it's the same.

 

I make a simple application with a loop that mesure the time between to loop.

 

The application write message if there a delta time > 50000ms

 

If I use the set_scheduler I have a message each 2s.

 

If I don't use the set_scheduler I have no message, the max time I read is 250us.

 

To be sure that that is not a software probleme with the gettimeofday I want to mesure it with an oscilloscpe on an IO.

 

Did you know how to access IO by soft ?

 

 

 

regards

 

Jean

QuoteReplyEditDelete

 

 

2011-04-15 10:33:43     Re: Real time

Michael Hennerich (GERMANY)

Message: 99890    On NOMMU you can simply read from an Async Memory Bank in user space

and connect the Scope to the corresponding /AMSx memory select strobe.

QuoteReplyEditDelete

 

 

2011-04-15 11:50:59     Re: Real time

Mike Frysinger (UNITED STATES)

Message: 99891   

 

use a GPIO:

  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs

QuoteReplyEditDelete

 

 

2011-04-15 12:15:41     Re: Real time

Jean Nicollerat (SWITZERLAND)

Message: 99893   

 

I make a test with gpio.

 

Generaly the IO the process is executed each  300-400 us.

 

But if I put the set_Scheduler I the process stop 50ms about each second.

QuoteReplyEditDelete

Attachments

    Outcomes