Sleep() isn't sleepy

Chris Johns chrisj at rtems.org
Wed Feb 8 21:34:00 UTC 2006


Ralph Preston wrote:
> Hello,
> 
> Yesterday I was testing some code and threw in a sleep() statement to aid
> debugging. It didn't work, and unfortunately, it seems to be more difficult
> that I imagined it would be.  The code compiles and runs but doesn't sleep,
> I haven't stepped through the code yet to see exactly what's happening to
> the sleep() since I thought it's probably a #define, or something simple
> that I've missed.
> 

The sleep call is code in the POSIX part of the score:

  cpukit/posix/src/sleep.c

It calls nanosleep.

> I know I enabled the posix api with --enable-posix.
> 
> I'm using the hello_world_c makefile as a starting point and added "timer"
> and "clock" to the managers.
> 
> To the code I added:
> #include <time.h>
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
> 
> Is there anything else I need to do to get sleep() to work?
> 

Did you check what sleep returns ? A signal can wake a sleep call and 
sleep returns the remaining seconds.

Regards
Chris



More information about the users mailing list