Пример #1
0
int __init round_jiffies_init(void) 
{
	printk("the round_jiffies test begin\n");
	unsigned long j=jiffies; //记录当前节拍 	
	unsigned long __result1=__round_jiffies(j,0); //参数j当前节拍,0是cpu编号
	unsigned long __result2=__round_jiffies(j,1);//参数j当前节拍,1是cpu编号
	unsigned long result1=round_jiffies(j);//参数j当前节拍
	unsigned long result2=round_jiffies(j);//参数j当前节拍
	printk("the jiffies is :%ld\n",j);//显示当前节拍
    	//显示函数调用结果	
	printk("the __result1 of __round_jiffies(j,0) is :%ld\n",__result1);
	printk("the __result2 of __round_jiffies(j,1) is :%ld\n",__result2);
	printk("the result1 of round_jiffies(j) is :%ld\n",result1);
	printk("the result2 of round_jiffies(j) is :%ld\n",result2); 
	printk("<0>out round_jiffies_init");
	return 0; 
} 
Пример #2
0
/**
 * __round_jiffies_relative - function to round jiffies to a full second
 * @j: the time in (relative) jiffies that should be rounded
 * @cpu: the processor number on which the timeout will happen
 *
 * __round_jiffies_relative() rounds a time delta  in the future (in jiffies)
 * up or down to (approximately) full seconds. This is useful for timers
 * for which the exact time they fire does not matter too much, as long as
 * they fire approximately every X seconds.
 *
 * By rounding these timers to whole seconds, all such timers will fire
 * at the same time, rather than at various times spread out. The goal
 * of this is to have the CPU wake up less, which saves power.
 *
 * The exact rounding is skewed for each processor to avoid all
 * processors firing at the exact same time, which could lead
 * to lock contention or spurious cache line bouncing.
 *
 * The return value is the rounded version of the @j parameter.
 */
unsigned long __round_jiffies_relative(unsigned long j, int cpu)
{
	/*
	 * In theory the following code can skip a jiffy in case jiffies
	 * increments right between the addition and the later subtraction.
	 * However since the entire point of this function is to use approximate
	 * timeouts, it's entirely ok to not handle that.
	 */
	return  __round_jiffies(j + jiffies, cpu) - jiffies;
}
Пример #3
0
/**
 * round_jiffies - function to round jiffies to a full second
 * @j: the time in (absolute) jiffies that should be rounded
 *
 * round_jiffies() rounds an absolute time in the future (in jiffies)
 * up or down to (approximately) full seconds. This is useful for timers
 * for which the exact time they fire does not matter too much, as long as
 * they fire approximately every X seconds.
 *
 * By rounding these timers to whole seconds, all such timers will fire
 * at the same time, rather than at various times spread out. The goal
 * of this is to have the CPU wake up less, which saves power.
 *
 * The return value is the rounded version of the @j parameter.
 */
unsigned long round_jiffies(unsigned long j)
{
	return __round_jiffies(j, raw_smp_processor_id());
}