LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can I implement an accurate timer under the heavey loading situation! (https://www.linuxquestions.org/questions/programming-9/how-can-i-implement-an-accurate-timer-under-the-heavey-loading-situation-369740/)

appforce 10-04-2005 01:45 PM

How can I implement an accurate timer under the heavey loading situation!
 
Hello! I hope I could measure some data (such as CPU Usage, Memory Usage..etc) every 1 second for my research to check the situation under the heavy loading (for example CPU usage 100%). However, if I use the function "settimer()", sometimes I can not get data for several seconds because of heavy loading. Therefore, the timer is not accurate. How can I implement the timer which can execute the timer function exactly every 1 second. I think the error about 100 ms is fine for me!
I know the RTAI kernel can help me to do that. But I just want to measure the data under some specific kernel. Is there any way can help me to do that without kernel modification or change. Thank you very much!

jim mcnamara 10-04-2005 02:50 PM

Set your priocess priority to realtime.

The nice() function allows privleged users to set priority values.

primo 10-04-2005 06:17 PM

You could try the function munlockall which prevents all pages associated with your process from being paged. Use this in conjunction with nice() and/or setpriority(). I'd suggest you google these terms in conjuction because there may be some tricks that help

appforce 10-04-2005 06:58 PM

Thanks for your response! I am appreciating that!:)
I will try to use mlockall and nice function to implement my program! Thanks again!


All times are GMT -5. The time now is 11:42 PM.