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 01-18-2006, 03:45 PM   #1
frakman1
LQ Newbie
 
Registered: Jan 2006
Posts: 4

Rep: Reputation: 0
Thread CPU Utilization


I am writing a kernel driver that reads a high data
rate dma-like channel. I am concerned that my reader
thread will consume all of the CPU's cycles sort of
like writing a while(1) loop and locking up the PC.

I was looking into writing some sort of load manager
within the reader thread in kernel code (or in a
seperate thread).

I was thinking of periodically reading the reader
thread's CPU utilization percentage and inserting a
sleep for some amount of time if it exceeds some
threshhold. This will allow other processes and
threads to run and stop the reader thread from
monopolizing the CPU

What is the easiest way in kernel code to get the
thread's CPU utilization so I can stop my thread from
taking over the CPU? Will I have to do so in a
seperate thread or can i do it from within the reader
thread?

Any thoughts on this subject would be extermely
valuable. Thank you in advance!

Frak
 
Old 01-19-2006, 01:09 PM   #2
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
you might be able to just set your process nice value like
int nice(19);
then it will get a short timeslice from the schedular
 
Old 01-20-2006, 01:16 PM   #3
frakman1
LQ Newbie
 
Registered: Jan 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks for the suggestion. I am just worried if I make it super-nice, which is like pushing it's priority way down, then it will just keep getting preempted by other higher priority tasks and never get to run. Is that possible?

I just find it hard to believe that this problem is unique to my driver, surely every driver in the world wants to process data as fast as it can get it. Shouldn't the linux scheduler make sure that no one task hogs the CPU?
 
Old 01-20-2006, 01:27 PM   #4
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
Quote:
Originally Posted by frakman1
Shouldn't the linux scheduler make sure that no one task hogs the CPU?
yep and thats why it does just that.
the only way for your driver to hog the situation is if you make a realtime FIFO pipe.
 
  


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
per process Cpu utilization kunal_patel22 Linux - Software 4 12-04-2007 05:14 PM
cpu and memory utilization laxmi_cs Linux - General 2 08-29-2005 04:06 PM
per process cpu utilization kunal_patel22 Linux - Software 1 05-19-2005 10:26 AM
getting total cpu utilization using c theog Programming 2 03-19-2005 04:41 PM
100 % CPU utilization Ganesh Kamat Linux - General 14 04-18-2003 01:34 PM

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

All times are GMT -5. The time now is 04:07 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