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