Venkat Natarajan
|
How to avoid busy wait when polling for completion status?
|
Venkat Natarajan
12/21/2011 9:21 PM
post90732
|
How to avoid busy wait when polling for completion status?
Hi,
I am trying to optimize a piece of code that checks for completion of an operation by polling the status regiser (of an
HW accelerator) in a loop. The operation takes about 400us and I would like to yield the CPU to other threads for this
duration of time so that the CPU is utilized efficiently. I tried inserting "usleep(400)" before checking the status
register. However, I noticed that the minimum time the thread sleeps is more than 1000us (on iMX53 Sabre board running
QNX) even if I try usleeep(1). For the current application sleeping for more than 1000us after initiating the operation
results in misssing other deadlines. So I have a couple of questions.
1. Is usleep(n) not working for small n a known feature/bug in QNX. I am new to QNX. Is there anything special one needs
to do for usleep(n) for small n to work?
2. Is there another way to relinquish control for say between 300 and 500 us so that the CPU utilization is better and
the deadline is not missed. This efficiency is important because this operation happens about 6 times evey 10ms.
Thanks,
Venkat
|
|
|