Ok, here is what I have. I changed nano sleep to use a local 64-bit value for the target expire time in jiffies. As much as MAX-INT/2-1 will be put in the timer at any one time. It loops till the target time is met or exceeded. The changes affect (clock)nanosleep only and not timers (they still error out for large values). Issues: The conversion of timespec to jiffies_64 is most easily done by the asm mpy instruction, which results in the required 64 bit result, but C doesn't want to do this sort of thing. I included a header file, originally written for the high-res code, that makes several of these functions available, both in an i386 asm version and a generic version. These functions were done mostly to do scaled math (hence the name sc_math.h) so I also included a "txt" file for the Documentation directory that talks about scaled math and, to some extent, about the routines in sc_math.h. What do you think? Oh, the code passes the tests I have, but I have not tried to test for very large sleep times. I can think of a couple of test that should be done.... tomorrow. -g Linus Torvalds wrote: > On Tue, 11 Mar 2003, Felipe Alfaro Solana wrote: > >> >>why not sleep(0)? > > > I think a much more likely (and correct) usage for big sleep values is > more something like this: > > do_with_timeout(xxx, int timeout) > { > struct timespec ts; > > ... set up some async event .. > ts.tv_nsec = 0; > ts.tv_sec = timeout; > while (nanosleep(&ts, &ts)) { > if (async event happened) > return happy; > } > .. tear down the async event if it didn't happen .. > } > > and here the natural thing to do in user space is to just make the "no > timeout" case be a huge value. > > At which point it is a _bug_ in the kernel if we return early with some > random error code. > > Linus > > -- George Anzinger george@mvista.com High-res-timers: http://sourceforge.net/projects/high-res-timers/ Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml