Forum Topic - Microseconds sleep on QNX: (6 Items)
   
Microseconds sleep on QNX  
Hi,

I need to generate microseconds sleep (in microseconds resolution) on QNX 6.6.0.
As time tick on the QNX system is 1 ms functions: "clock_nanosleep()" and 
"nanosleep()" do not provide microseconds sleep accuracy. 
Is there any other reliable method to sleep over such short period of time (other than nanospin() function which 
consumes too much CPU)?

thank you for any help,
regards
Re: Microseconds sleep on QNX  
Il 25/08/2014 15:54, Radoslaw Kudaj ha scritto:
> Hi,
>
> I need to generate microseconds sleep (in microseconds resolution) on QNX 6.6.0.
> As time tick on the QNX system is 1 ms functions: "clock_nanosleep()" and
> "nanosleep()" do not provide microseconds sleep accuracy.
> Is there any other reliable method to sleep over such short period of time (other than nanospin() function which 
consumes too much CPU)?
>
> thank you for any help,
> regards
A reliable usleep may dependes by platform/CPU  You are using and if
You can allows or not a preemption during usleep .

If Your system has an hardware timer available , you can use it to 
generate an
interrupt for You and do works in ISR or just send a pulse to an 
interrupt thread.
Or You can read the timer in a loop and exit after the desidered us are 
elapsed
(be sure to set Your thread priority in order to gain the desidered 
accuracy).

M.




Re: Microseconds sleep on QNX  
Mario Sangalli schrieb:
> Il 25/08/2014 15:54, Radoslaw Kudaj ha scritto:
>> Hi,
>>
>> I need to generate microseconds sleep (in microseconds resolution) on QNX 6.6.0.
>> As time tick on the QNX system is 1 ms functions: "clock_nanosleep()" and
>> "nanosleep()" do not provide microseconds sleep accuracy.
>> Is there any other reliable method to sleep over such short period of time (other than nanospin() function which 
consumes too much CPU)?
>>
>> thank you for any help,
>> regards
> A reliable usleep may dependes by platform/CPU  You are using and if
> You can allows or not a preemption during usleep .
>
> If Your system has an hardware timer available , you can use it to 
> generate an
> interrupt for You and do works in ISR or just send a pulse to an 
> interrupt thread.
> Or You can read the timer in a loop and exit after the desidered us are 
> elapsed
Mario wrote: 

"other than nanospin() function which consumes too much CPU)".

that means polling of a timer could not be a solution.

My proposal:

if your target system is x86 based go with the IRQ 8 (RTC) ... it should be available again with QNX 6.6.
If you are working with an non-x86 SoC, then have a look to its hardware resources for hardware timers.

Regards

--Armin

> (be sure to set Your thread priority in order to gain the desidered 
> accuracy).
>
> M.
>
>
>
>
>
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post111535
> To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
>

Attachment: HTML sf-attachment-mime26381 2.41 KB
Re: Microseconds sleep on QNX  
> Hi,
> 
> I need to generate microseconds sleep (in microseconds resolution) on QNX 6.6.
> 0.

You need an  accurracy of +-1 usec ?
How long is the minimal duration, you need to sleep ?

-Michael

> As time tick on the QNX system is 1 ms functions: "clock_nanosleep()" and 
> "nanosleep()" do not provide microseconds sleep accuracy. 
> Is there any other reliable method to sleep over such short period of time 
> (other than nanospin() function which consumes too much CPU)?
> 
> thank you for any help,
> regards


Re: Microseconds sleep on QNX  
+-1 usec would be the best but +-5usec is also acceptable.
One good solution is using HW timer and interrupt, like mario described above, 
but I wonder whether there is another way.

thank you,
Radek
Re: Microseconds sleep on QNX  
> +-1 usec would be the best but +-5usec is also acceptable.
> One good solution is using HW timer and interrupt, like mario described above,
Yes, but you have still not told us the absolute duration of your delay and how often you want to call your special 
sleep.

Well, if you are using a fast machine, you can lower the ticksize.
1 ms was a good choice for 386 and 16 Mhz. 
On a 4 years old  core2 we use 10 us ticksize.
So your minimal sleep would be <= 20 usec.

-Michael