Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

nanosleep hangs?

807557Apr 29 2010 — edited Jun 17 2010
Hello,
I have a program which calls nanosleep many times and sometimes hangs on an x86 box running
[appn1:root] / $ uname -a
SunOS appn1 5.10 Generic_137112-08 i86pc i386 i86pc
while running fine on
SunOS sun03 5.10 Generic_127128-11 i86pc i386 i86pc
Here is the code boiled down to a minimum:
#include <stdio.h>
#include <time.h>
#include <errno.h>
#include <strings.h>

#define DELAY 1000000

int main()
{
   struct timespec req;
   req.tv_sec = 0;
   req.tv_nsec = 1;
   
   for (;;)
   {
      for (int i=0; i<DELAY; ++i)
         if (nanosleep(&req,NULL) < 0)
            perror("Squeak");
      printf("Tick\n");
   }
}
pstack shows the hang is happening in the nanosleep itself:
[appn1:root] / $ pstack 25221
25221:  dodgysleep
 fed64aa7 nanosleep (8047e0c, 0)
 fef92b67 nanosleep (8047e0c, 0) + 1b
 080509f0 main     (1, 8047e44, 8047e4c, 8050898) + 30
 0805092d _start   (1, 8047ef0, 0, 8047efb, 8047f07, 8047f0e) + 7d
[appn1:root] / $ 
Am I doing something silly? Does anybody know what is going on?

Thanks
-- Steve
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 15 2010
Added on Apr 29 2010
5 comments
1,292 views