Hi On Thu, Jan 8, 2009 at 9:43 PM, Bruce Rowen <browen@xxxxxxxxxxxx> wrote: > Hello, > > I've been deferring a problem I ran into a few months back and I figure a > new year is a good time to readdress it. > > I have a loadable module that controls some hardware. Within this hardware > are various bits that need to be strobed (i.e set for a minimum specified > time and then reset). I have several ioctl() functions set to do this, but > when I tried using a usleep() to force a minimum delay, the system hanged. I > did a work around by using the CPU internal register timer rdtscl(), but > this has the side effect of tying up the CPU instead of allowing a > reschedule as (hopefully) a usleep() would do. > > An example of what I'd like to do is: > > ... > > case STROBE_RESET: > { > hwRegister |= RESET_MASK; > usleep (10000L); // hold bit high for at least 10ms > hwRegister &= ~RESET_MASK; > break; > } > ... > > > Some delays are shorter (i.e. 20us). > > What (if any) taboos exist for using sleep() in a kernel ioctl call and what > alternatives exist? it's not a taboo. In your case, i think it's simply because you can not reschedule because it will screw something (are you holding a lock or something? probably some sequences of inb/outb must be done in sequence ?). If yes, then busy wait is probably your only way to delay. > Kernel is 2.6.13 w/preemption, soon to be moving to a later version, regards, Mulyadi. -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ