[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BOUNCE rtl@rtlinux.org: Approval required: Non-member submissionfrom [Klaas Gadeyne <klaas.gadeyne@mech.kuleuven.ac.be>] (fwd)



>From owner-rtl Sat May 19 12:51:43 2001
Received: from Myrtille.localdomain (dial-12.kulak.ac.be [193.190.181.236])
	by hq.fsmlabs.com (8.11.2/8.11.2) with ESMTP id f4JIpdr02785
	for <rtl@fsmlabs.com>; Sat, 19 May 2001 12:51:41 -0600
Received: from localhost (kgadeyne@localhost)
	by Myrtille.localdomain (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP id f4JImHK00671
	for <rtl@fsmlabs.com>; Sat, 19 May 2001 20:48:17 +0200
X-Authentication-Warning: Myrtille.localdomain: kgadeyne owned process doing -bs
Date: Sat, 19 May 2001 20:48:17 +0200 (CEST)
From: Klaas Gadeyne <klaas.gadeyne@mech.kuleuven.ac.be>
Sender: <kgadeyne@heleen.local>
To: <rtl@fsmlabs.com>
Subject: Re: [rtl] gethrtime
In-Reply-To: <3B04D002.1CB12216@b2i-toulouse.com>
Message-ID: <Pine.LNX.4.31.0105192040310.610-100000@Myrtille.localdomain>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

> oneshot mode. Periodically, the next wake up date is calculated in clock
> units. Because the period in clock unit is not equal to the period in
> nanoseconds, a drift should be seen, especially after a large number of
> periods.
>
> In fact, after having done this test, I did not see such a drift. Do not
> think I am disapointed, I'm not ! I would like to know wether I am wrong
> in my assumptions or not, and if not, how the gethrtime function manages
> not to create a drift.

I don't know wether you're wrong in your assumptions but a couple of weeks
ago I was working on some steppermotor software and there there was
obviously some drift when just using a call (for constant speed)

while(1)
{
	pthread_make_periodic_np(pthread_self(),gethrtime()+period,0);
	pthread_wait_np();
	outb(...);
}

I don't know wether the drift is due to the rounding process, but the
jitter alone is responsible for drift.

To avoid drifting errors you can use "absolute timing", ie something like

next_fire_time = somewhere in the future;
while(1)
{
	pthread_make_periodic_np(pthread_self(),next_fire_time,0);
	pthread_wait_np();
	outb(...);
	next_fire_time += period;
}

Hope this was somewhat an answer to your question,

regards

klaas