LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2011, 10:49 PM   #1
neyshule
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Rep: Reputation: 0
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.
 
Old 10-08-2011, 11:16 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

Could we see the code, if you don't mind?

Cheers,

Josh
 
Old 10-09-2011, 12:09 AM   #3
neyshule
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Original Poster
Rep: Reputation: 0
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???

Last edited by neyshule; 10-09-2011 at 12:10 AM.
 
Old 10-09-2011, 06:11 AM   #4
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by neyshule View Post
The code is long
Then why not develop a small application that attempts to duplicate the issue? Perhaps all that is wrong is your usage of nanosleep?
 
Old 10-09-2011, 10:30 PM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tickless Kernel yet still get many IRQ0 timer interrupts sixerjman Linux - Kernel 2 02-23-2011 02:31 AM
How to mask local timer interrupts in user space? davehfa Linux - General 3 10-31-2010 08:59 AM
[SOLVED] generating timer interrupts in C yaami Programming 3 07-24-2010 02:59 AM
Huge amount of "PHP Notice:" -> huge logs Braynid Linux - Software 4 03-18-2008 06:35 AM
Need to disable timer or all interrupts from user space G35Coupe Linux - General 0 11-16-2004 12:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration