--279707946-1773431784-931467146=:435
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
On Wed, 7 Jul 1999, Mattias Engdegård wrote:
> In linux-kernel you wrote:
>
> >I don't accept that. gettimeofday() knows pretty good where inside the
> >tick period the system is. Rounding up to the next tick (instead of
> >rounding up the delta to the tick accuracy, and then rounding up to
> >the next tick - double rounding to me) is possible, and would allow to
> >have a 0-10 ms sleep period, too. It's not just a single line like
> >deleting a + 1 in case timeout is not zero, but I believe it's doable.
> >I'll prepare a patch to prove it.
>
> I've been thinking about this as well, and think it should not be hard
> at all. The gettimeoffset functionality isn't exported from the
> machine-dependent files, so this has to be fixed for all architectures.
> A small problem is that some of them are quite optimized (look at the sparc
> code), and people are going to complain if we add a single cycle to the
> gettimeofday path. Please tell me if you have a patch prepared.
I've prepared a first patch (x86 only for now), which does what I have in
mind. It exports gettimeoffset() from arch/xx/kernel/time.c (only for x86
at the moment), never undersleeps on nanosleep (sleeps to the nearest tick
after timeout), and never oversleeps on select (sleeps to nearest tick
before timeout). I did some short tests to prove this, and it seems to
work. The basics are done in timespec_to_jiffies
There's a known flaw in my implementation: since timespec_to_jiffies just
provides a delta, the jiffies could have been incremented after I rounded
up, which gives an unnecessary tick to wait in that case. Rewriting that
so that timespec_to_jiffies adds jiffies itself (with taking overflows
into account) is more time-consuming; it's on my ToDo list.
A patch for other architectures where it is easy to port without testing
will follow, but for the more complicated parts (SPARC), I'll very likely
leave the challange of providing gettimeoffset() to the maintainers of
that platform ;-).
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
--279707946-1773431784-931467146=:435
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="timer.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.9907082252260.435@granny.paysan.nom>
Content-Description:
Content-Disposition: attachment; filename="timer.diff"
LS0tIGxpbnV4LTIuMy45L2FyY2gvaTM4Ni9rZXJuZWwvdGltZS5jLm9yaWcJ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gPSBqaWZmaWVzOw0KKyNlbmRpZg0K
KwkJb2Zmc2V0ID0gZ2V0dGltZW9mZnNldCgpOw0KKyNpZmRlZiBUMkpfV0lU
SF9KSUZGSUVTDQorCX0gd2hpbGUgKGppZmZpZXMxICE9IGppZmZpZXMpOw0K
KyNlbmRpZg0KKw0KKwluc2VjICs9IG9mZnNldDsNCiAJbnNlYyAvPSAxMDAw
MDAwMDAwTCAvIEhaOw0KLQlyZXR1cm4gSFogKiBzZWMgKyBuc2VjOw0KKwly
ZXR1cm4gSFogKiBzZWMgKyBuc2VjDQorI2lmZGVmIFQySl9XSVRIX0pJRkZJ
RVMNCisJCSsgamlmZmllcw0KKyNlbmRpZg0KKwk7DQogfQ0KIA0KIHN0YXRp
YyBfX2lubGluZV9fIHZvaWQNCg==
--279707946-1773431784-931467146=:435--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/