I need a way to cause a delay in a program that can vary from 0.000125 seconds to .5 seconds, therefore giving me between 2000 samples per second and 2 respectively. Without a sleep I max out just over 2000 samples per second, but as soon as I put some sort of delay or sleep in I barely get 50 samples per second. I have tried nanosleep and the best I got was 50 samples per second.
OS = Linux Kernel
Compiler = gcc
Thanks for any help you can offer