LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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-27-2008, 04:13 PM   #1
skibud2
Member
 
Registered: Sep 2003
Location: Waltham MA
Distribution: Mandriva 2007 w/ KDE
Posts: 87

Rep: Reputation: 15
Driver IO Busywait Kernel Driver Question


I have a driver that does the following:

// Kind of like a serial driver with no interrupt

for (c in buff){
write_to_reg(c);
while(statusreg & BUSY_MASK); // busy wait for operation to complete
}

Naturally, this causes a lot of busy waiting, and the CPU usage goes up. Is there a good way to reduce the CPU usage in this circumstance?

Thanks!
 
Old 10-27-2008, 04:19 PM   #2
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 31
This is just off the top of my head but I think you could put a 'sleep' call inside your loop and the process would go to sleep for a bit before it tried the while statement again. Granted the smallest sleep increment is a second I think so that is quite long in computer terms, but it may solve your problem
 
Old 10-27-2008, 08:19 PM   #3
skibud2
Member
 
Registered: Sep 2003
Location: Waltham MA
Distribution: Mandriva 2007 w/ KDE
Posts: 87

Original Poster
Rep: Reputation: 15
This is all being done in an ioctl call. Anyone else have any ideas?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
kernel driver question 2.6.12 marcm Programming 1 10-10-2008 06:24 AM
Linux kernel driver question niteshg Programming 11 08-06-2008 01:21 AM
Wireless driver/kernel question Scrapnon Linux - Hardware 1 08-20-2007 11:55 PM
Merging driver w/ kernel question Palamides Slackware 4 05-20-2005 04:02 AM
kernel question - IDE-chipset driver bailmann Debian 1 01-14-2005 09:22 AM


All times are GMT -5. The time now is 11:04 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration