(Fwd:) [ebo@leml.la.asu.edu: wierd timing...] us delay timing

Mark Taylor plug-devel@lists.PLUG.phoenix.az.us
Mon May 13 15:55:02 2002


If you are willing to write and load a kernel module, open it
as a device driver, and make ioctl calls to it from your process
read on.

The module can call the kernel function udelay defined in
<linux/delay.h> to busy wait a given number of microseconds.
A full millisecond is getting around to the upper limit for
busy waiting.
You also risk that your ioctl call will not return immediately after
the delay since it is possible another process will be scheduled.

Such a module exists for 2.2 kernels and is described by
http://www.linuxgazette.com/issue58/taylor.html
(shameless plug for my article :) )

This module has been tested with application level code to bit
bang an I2C bus (SMBus) host controller implemented with two
general purpose discrete input/output pins.  The I2C bus protocol
has several single digit microsecond waits.

I have updated and compiled the module for 2.4 kernels, but have not
completed the work necessary to publish it.

Mark Taylor


Gontran Zepeda wrote:

> ----- Forwarded message from "John (EBo) David" <ebo@leml.la.asu.edu> -----
>
> Date: Mon, 13 May 2002 02:39:27 -0700
> To: "plug-discuss@lists.PLUG.phoenix.az.us" <plug-discuss@lists.PLUG.phoenix.az.us>
> X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.7-10smp i686)
> Reply-To: plug-discuss@pluglist.mybutt.net
> From: "John (EBo) David" <ebo@leml.la.asu.edu>
> Subject: wierd timing...
>
> Using a trick I learned years ago I was using select to "wait" for some
> number of microseconds...  Using it for a new program I noticed some
> weird timing.  After reading the man pages I found:
>
>        On Linux, timeout is modified to  reflect  the  amount  of
>        time not slept; most other implementations do not do this.
>        This causes problems both  when  Linux  code  which  reads
>        timeout  is  ported  to  other operating systems, and when
>        code is ported to Linux that reuses a struct  timeval  for
>        multiple  selects  in  a  loop  without reinitializing it.
>        Consider timeout to be undefined after select returns.
>
> Cruising the code I found (in linux/personality.h) that one can set
> "STICKY_TIMEOUTS" and force the behavior back to other definitions.
> Question is, how to select to sticky.  As a note I also found that
> pselect is not found in the standard headers even though it is defined
> in the man pages and is part of the IEEE Std 1003.1g-2000 (POSIX.1g).
>
> so my questions are:
>
>   1) does anyone know how to set select for sticky timeouts, and/or
>   2) does anyone have some sample code for suspending a process for less
> than a millisecond?
>
>  EBo --
>
> ----- End forwarded message -----
> _______________________________________________
> PLUG-devel mailing list  -  PLUG-devel@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel