HELP: nanosleep causes huge amount of local timer interrupts
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
HELP: nanosleep causes huge amount of local timer interrupts
Hi all:
I have a user mode application which uses nanosleep in a while(1) loop, unfortunately it brings a huge amount of local time interrupts, which greatly damage the application performance, I don't know why nanosleep can cause this large increase on local timer interrupts?? How should I do to eliminate this unwanted interrupts. Thanks for your help.
The code is long, here is the main framework:
while(1){
check some flag;
if true,nanosleep;
use memcpy to copy from one memory area to anthoer;
}
If I don't use nanosleep, everything works fine without huge LTI, but the CPU usage is 100%.
The weird thing is this code works well in the old environment, after I reformat the disk and reinstall the linux the behavior changes.(same machine and kernel), what could be the difference, some configuration???
Why not use a pthread condition instead of a flag and nanosleep? If you still need the flag, you should be able to broadcast the condition when the flag gets updated. nanosleep isn't really a good way to synchronize threads and processes. If necessary, you can share a condition between different processes, also.
Kevin Barry
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.