lkml.org 
[lkml]   [2011]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectmsleep() an load average

LDD Chapter 7 says "In general, if you can tolerate longer delays than
requested, you should use schedule_timeout, msleep or ssleep.".

Following this rule, my kernel thread does:
while(1) msleep(1000);

Seconds later userspace guys start whining: "Your driver is evil,
loadavg is 1 and we did not even start our fancy application".

I say: "No, my code is perfectly fine, I followed LDD to the letter."

So the userspace guys head back to their cave, only to return after 5
hours of googling: "Hey, we know what you are doing. Your kernel thread
does uninterruptible sleeps. Wikipedia says, this means you are probably
waiting for disk activity."

Since I don't like having those whining userspace guys around I change
my code, reluctantly:
while(1) msleep_interruptible(1000);

Seconds later they say: "All hail great kernel hacker! You fixed it in
no time."

I appreciate their admiration, but still there are doubts in my mind: Is
this code really any better? Is the loadavg metric broken beyond repair?
Should I really avoid msleep, just to stop those userspace guys from
whining?
The truth must be out there ...

Cheers
Dirk




\
 
 \ /
  Last update: 2011-05-04 14:47    [W:0.043 / U:1.836 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site