Re: easy softball jiffies quest(ion)

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

 



As others have said, maybe jiffies isn't the time value you want.  
However, clock ticks are available in userland via the times system 
call.

Note the warning at the end; you'll have to do your comparisons 
correctly or fail when the counter overflows.

man 2 times:

	...
	Return Value
		The function times returns the number of clock ticks that have
		elapsed since an arbitrary point in the past.  For Linux this
		point is the moment the system was booted.  This return
		value may overflow the possible range of type clock_t.


On Friday 08 April 2005 10:02 pm, philip dahlquist wrote:
> hi,
>
> i'm on a quest to get access to jiffies in user space so i can write
> a simple stepper motor driver program.  i co-opted the "#includes"
> list from alessandro rubini's jit.c file from "linux device drivers"
> to write jfi.c.
>
> this is it:
> ------------------------------------------------------------------
> #include <linux/config.h>
> #include <linux/module.h>
> #include <linux/moduleparam.h>
> #include <linux/init.h>
>
> #include <linux/time.h>
> #include <linux/timer.h>
> #include <linux/kernel.h>
> #include <linux/proc_fs.h>
> #include <linux/types.h>
> #include <linux/spinlock.h>
> #include <linux/interrupt.h>
>
> #include <asm/hardirq.h>
>
>
> int main(void)
> {
> 	unsigned long j = jiffies + (50 * HZ);
> 	printf("start jiffies = %9li\n",jiffies);
> 	while(jiffies < j)
> 		;
>
> 	printf("done jiffies = %9li\n", jiffies);
> 	return 0;
> }
[[ Snip! ]]

-- 
James Cleverdon
IBM LTC (xSeries Linux Solutions)
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot comm
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux