Matt Wozniski wrote: > I have two threads in my program, which runs on Solaris 8 SPARC with Sun > Studio 11. I would like the thread containing main() to spawn a new thread to > perform a complicated task for up to five minutes, but kill it if it takes > too long. I've been trying to accomplish this with a pthread_cond_timedwait, > but it seems that this function can sometimes return ETIMEDOUT after nowhere > near the correct amount of time has elapsed. A post at > http://dbforums.com/showthread.php?t=769084 suggests that this might be > caused by an hourly NTP synchronization changing the system clock time and > invalidating the waiting timer. Is there any good way to work around this > issue, or to handle a thread timing out more intelligently? > > > This message posted from opensolaris.org > _______________________________________________ > opensolaris-code mailing list > [email protected] > http://mail.opensolaris.org/mailman/listinfo/opensolaris-code >
It sounds like the solution to this is to run ntpd to discipline the local clock, rather than running ntpdate out of cron. "Hard setting" the system clock is usually a bad idea. The other thing is that you can code for this and "compare" the clock times to see if you have timed out prematurely. Of course, if someone sets the clock backwards in time, then you could experience the problem where the application doesn't timeout in a "timely" fashion. Pardon the pun. Seriously, change to disciplining the clock rate, and only ever change the system clock at start of day or when the clock falls out of synchronization badly (usually from being disconnected from an NTP network), rather than calling ntpdate or rdate. -- Garrett D'Amore, Principal Software Engineer Tadpole Computer / Computing Technologies Division, General Dynamics C4 Systems http://www.tadpolecomputer.com/ Phone: 951 325-2134 Fax: 951 325-2191 _______________________________________________ opensolaris-code mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
