public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Cleverdon <jamesclv@us.ibm.com>
To: philip dahlquist <dahlquist@kreative.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: easy softball jiffies quest(ion)
Date: Tue, 19 Apr 2005 20:36:14 -0700	[thread overview]
Message-ID: <200504192036.14994.jamesclv@us.ibm.com> (raw)
In-Reply-To: <20050409010252.2eca2177.dahlquist@kreative.net>

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

  parent reply	other threads:[~2005-04-20  3:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-09  5:02 easy softball jiffies quest(ion) philip dahlquist
2005-04-09  5:50 ` Vadim Lobanov
2005-04-20  3:36 ` James Cleverdon [this message]
     [not found] <3Rgon-7E2-3@gated-at.bofh.it>
2005-04-11  2:39 ` Robert Hancock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200504192036.14994.jamesclv@us.ibm.com \
    --to=jamesclv@us.ibm.com \
    --cc=dahlquist@kreative.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox