From: Ben Greear <greearb@candelatech.com>
To: "Alexandre P. Nunes" <alex@PolesApart.wox.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: some questions using rdtsc in user space
Date: Fri, 02 Aug 2002 21:31:51 -0700 [thread overview]
Message-ID: <3D4B5CB7.9020503@candelatech.com> (raw)
In-Reply-To: 3D4ABCA3.3020402@PolesApart.wox.org
Have you just tried spinning in a tight loop using gettimeofday
to get the time? It's not exactly efficient, but if you need that
kind (200ns) of precision that is about the only way. You'll still
be stuck with 1usec precision since that is as good as gettimeofday
can do, but that's a far sight better than 10ms or even 2ms.
Ben
Alexandre P. Nunes wrote:
> Hi,
>
> Both I and a friend have with an interesting scenario, maybe someone can
> help us.
>
> We have to access a device connected to parallel port, which works in
> the following way: you send a byte to the port, to turn some bits on
> (reflecting on some pins on the parallel port), which is interpreted by
> the device as a command. Then you are supposed to sleep about ~200ns
> (maybe more, just can't be much less), and then you send a byte which is
> received by the device as data, pertinent to command.
>
> We wrote a program which accomplishes this by doing outb() to
> appropriate address(es), followed by usleep(1), but that seems to take
> about 10 ms at average or so, which is far from good for our application.
>
> I read somewhere that putting the process in real-time priority could
> lead the average to 2ms, but I had this though that I could solve this
> by using rdtsc instruction, because as far as I know it won't cause a
> trap to kernel mode, which maybe expensive, am I right?
>
> I don't have the need to use real time linux (though I'm considering
> real-time priority), nor desperate time precision needs, what I don't
> want is to have huge delays. I cannot relay on the low-latency patches
> too, if possible (though I know it could help), because the program
> will eventually run on standard kernels.
>
> If using rdtsc is a good way, someone knows how do I do some sort of
> loop, converting the rdtsc difference (is it in cpu clocks, right?) to
> nano/microseconds, and if there could be bad behaviour from this (I
> believe there could be some SMP issues, but for now this is irrelavant
> for us).
>
>
> Thanks!
>
>
> Alexandre
>
> P.S..: carbon-copy me, since I'm not subscribed to the list.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Ben Greear <greearb@candelatech.com> <Ben_Greear AT excite.com>
President of Candela Technologies Inc http://www.candelatech.com
ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
next prev parent reply other threads:[~2002-08-03 4:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-02 17:08 some questions using rdtsc in user space Alexandre P. Nunes
[not found] ` <3D4ACF11.FD7BB5B5@nortelnetworks.com>
2002-08-02 19:05 ` Alexandre P. Nunes
2002-08-03 4:31 ` Ben Greear [this message]
[not found] <Pine.LNX.4.33.0208021430590.2710-100000@coffee.psychology.mcmaster.ca>
2002-08-02 19:29 ` Alexandre P. Nunes
2002-08-02 20:58 ` george anzinger
[not found] <006901c23a81$08f52170$0100a8c0@brianwinxp>
2002-08-03 18:18 ` Alexandre Pereira Nunes
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=3D4B5CB7.9020503@candelatech.com \
--to=greearb@candelatech.com \
--cc=alex@PolesApart.wox.org \
--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