[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: [rtl] rt_task_make_periodic and failed deadlines



On 14 Apr 1999, Kenneth Jacker wrote:

> Say rt_task_make_periodic requests a RT task to run every 100ms, but
> the task (unknowingly) requires 125ms to run.  Or another scenario: a
> RT task is scheduled at a rate faster than the RTL scheduler is able
> to repeatedly invoke it.
> 
> Can these situations be detected at runtime?  If so, how?
> 

Use the rdtsc() instruction, for i586-class machines and above,
which provides a counter tied to the CPU cycle clock. You can make a
couple calls to this instruction on each side of your task, or some
sub-part of your task, take the difference and calculate back to a
meaningful time unit by knowing the CPU speed (200 MHz PPro = 5ns/rdtsc()
unit, for example).

You can find the rdtsc() instruction in
/usr/include/linux/include/adm-i386/system.h

If you need to estimate the CPU clock, you can use something like

/* Code lifted from the joy-analog driver of Vojtech Pavlik 1999 */ 
#define GET_TIME(x)	__asm__ __volatile__ ("rdtsc" : "=a" (x) :: "dx" )
int cpu_speed_kHz(void)
{
	unsigned int t1, t2, t3;
	unsigned long flags;

	save_flags(flags);
	cli();
	GET_TIME(t1); /* GET_TIME is your rdtsc() macro */
	udelay(1000);
	GET_TIME(t2);
	GET_TIME(t3);
	restore_flags(flags);

	return CPU_clock_kHz = (t2-t1) - (t3-t2);
}

*** NOTE *** : For RTL modules, this should be called in the init_module()
function only!!!! (Just store the speed away in a global).

-Don

--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail majordomo@rtlinux.cs.nmt.edu OR
echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.cs.nmt.edu
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/