Messages in this thread | | | Date | Sat, 23 Jul 2005 12:06:26 -0700 | From | Nishanth Aravamudan <> | Subject | Re: [PATCH] Add schedule_timeout_{interruptible,uninterruptible}{,_msecs}() interfaces |
| |
On 23.07.2005 [19:01:57 +0200], Roman Zippel wrote: > Hi, > > On Sat, 23 Jul 2005, Nishanth Aravamudan wrote: > > > set_current_state(TASK_{,UN}INTERRUPTIBLE); > > schedule_timeout(msecs_to_jiffies(some_constant_msecs)); > > > > just have an interface that allows > > > > schedule_timeout_msecs_{,un}interruptible(some_constant_msecs); > > > > and push the jiffies conversion to common code? > > What's wrong with just: > > schedule_timeout_{,un}interruptible(msecs_to_jiffies(some_constant_msecs));
Nothing, I suppose. I just prefer directly using msecs. I understand your point more now, I think. You are worried about those people that actually use the return value of schedule_timeout().
> The majority of users use a constant, which can already be converted at > compile tile. > Additionally such an interface also had to return a ms value and instead > of that constant conversion, the user is better off to work with jiffies > directly.
So, I just spent a good hour looking at every caller of schedule_timeout() which actually stores the return value. Beyond the other wrappers for it (wait_event(), wait_for_completion(), sys_nanosleep(), etc., which I will leave alone using schedule_timeout() until I can change *their* parameters ;) ), I found two cases.
1) Sleep, see if you actually slept the whole time:
remainder = schedule_timeout(some_value_in_jiffies); if (!remaining) report_timeout();
2) Sleep in a loop, keeping track of remaining timeout each iteration:
while (timeout) { do_some_stuff(); timeout = schedule_timeout(timeout); if (some_condition) break; }
Clearly, neither needs to use jiffies. The former only wants to know if the full timeout elapsed. I didn't find anyone returning that stored value (again, excepting wrapper interfaces) to the caller. They just want to know if they should return -ETIME{,DOUT}. The latter just is a means to guarantee the entire time is slept, but doesn't care about the units.
Now, some of these might depend on structures which have members with jiffy-unit values. But I will be more than happy to try and either leave them alone or convert those structures. We'll see about that on a case-by-case basis?
Thanks, Nish - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |