LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-27-2008, 03: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, 03:19 PM   #2
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 32
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, 07: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



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

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

All times are GMT -5. The time now is 04:40 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
Open Source Consulting | Domain Registration