"sleep" "select" system call not work correctly when linkingwith multithread libray--FreeBSD 4.5

M. Warner Losh imp at bsdimp.com
Fri Feb 25 02:18:38 GMT 2005


In message: <200502250205.j1P25hEU004737 at rover.village.org>
            "River" <river_robert at yahoo.com.cn> writes:
: Many thanks for your reply. Did the lastest FreeBSD fix this bug?
: And which version? 

I believe that 5 fixes this bug, or at least mostly fixes things
(since there's at least one pthread API that uses absolute time).
However, I've not verified this on 5.

: Because our OS is based on FreeBSD 4.5 and can not port to other
: FreeBSD easily, Any method to fix it in 4.5? Thanks.

The only fix that I could come up with was to base everything on
uptime rather than system time.  However, I ran into snags because the
pthread's API is stupid:

     int
     pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
         const struct timespec *abstime);

abstime is lame, because it doesn't cope well with system time
changing.

Your best bet is to make sure that the system time doesn't step after
your application starts.  This means you'll likely need to wait for
ntpd to step the time, or use ntpdate to get things close and tell
ntpd not to step things.

Warner


More information about the freebsd-hackers mailing list