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 |
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 |
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? |
Quote:
the only way for your driver to hog the situation is if you make a realtime FIFO pipe. |
All times are GMT -5. The time now is 01:40 PM. |