[Patch] Re: usleep granularity

Bernd Paysan (bernd.paysan@gmx.de)
Sat, 10 Jul 1999 14:36:54 +0200 (MEST)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

--279707946-350437960-931610214=:6704
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Thu, 8 Jul 1999, Bernd Paysan wrote:

> 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 ;-).

Ok, here's the patch that should work on all architectures (with fingers
crossed). At least the SPARC part wasn't all that difficult, since 2.3.9
already contains the necessary code. The first patch contained a big flaw,
since I mixed microseconds with nanoseconds (gettimeoffset returns
microseconds, whereas timespec is in nanoseconds). Oops. Don't know how it
slipped through my tests.

For those architectures without synced CPU tick counter (Alpha, PPC), I
just return worst case delta from gettimeoffset. I didn't yet fix the
problem with jiffies added later. And it's still a patch against 2.3.9,
even though 2.3.10 is out.

For the timer sync problem on Alpha, I suggest using an array of
state.partial_tick[MAX_CPUs], and compute that value in
smp_percpu_timer_interrupt instead of just doing it for the boot CPU. I
don't know if this sort of fix can be used for the PPC, too.

Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/

--279707946-350437960-931610214=:6704
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="timer.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.9907101436540.6704@granny.paysan.nom>
Content-Description:
Content-Disposition: attachment; filename="timer.diff"

LS0tIGxpbnV4LTIuMy45L2FyY2gvYWxwaGEva2VybmVsL3RpbWUuYy5vcmln
CVNhdCBKdWwgMTAgMTM6NDk6MzIgMTk5OQ0KKysrIGxpbnV4LTIuMy45L2Fy
Y2gvYWxwaGEva2VybmVsL3RpbWUuYwlTYXQgSnVsIDEwIDEzOjU3OjU3IDE5
OTkNCkBAIC0zMjMsNiArMzIzLDQ0IEBADQogCQlw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Pj0gKE1BWF9KSUZGWV9PRkZTRVQgLyBIWikpDQorI2lm
ZGVmIFQySl9XSVRIX0pJRkZJRVMNCisJCXJldHVybiBqaWZmaWVzICsgTUFY
X0pJRkZZX09GRlNFVDsNCisjZWxzZQ0KIAkJcmV0dXJuIE1BWF9KSUZGWV9P
RkZTRVQ7DQotCW5zZWMgKz0gMTAwMDAwMDAwMEwgLyBIWiAtIDE7DQorI2Vu
ZGlmDQorDQorI2lmZGVmIFQySl9XSVRIX0pJRkZJRVMNCisJZG8gew0KKwkJ
amlmZmllczEgPSBqaWZmaWVzOw0KKyNlbmRpZg0KKwkJb2Zmc2V0ID0gZ2V0
dGltZW9mZnNldCgpOw0KKyNpZmRlZiBUMkpfV0lUSF9KSUZGSUVTDQorCX0g
d2hpbGUgKGppZmZpZXMxICE9IGppZmZpZXMpOw0KKyNlbmRpZg0KKw0KKwlu
c2VjICs9IG9mZnNldCAqIDEwMDA7DQogCW5zZWMgLz0gMTAwMDAwMDAwMEwg
LyBIWjsNCi0JcmV0dXJuIEhaICogc2VjICsgbnNlYzsNCisJcmV0dXJuIEha
ICogc2VjICsgbnNlYw0KKyNpZmRlZiBUMkpfV0lUSF9KSUZGSUVTDQorCQkr
IGppZmZpZXMNCisjZW5kaWYNCisJOw0KIH0NCiANCiBzdGF0aWMgX19pbmxp
bmVfXyB2b2lkDQo=
--279707946-350437960-931610214=:6704--

-
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/