| Summary: | poll misconverts milliseconds to nanoseconds | ||
|---|---|---|---|
| Product: | Base System | Reporter: | davids <davids> |
| Component: | misc | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 3.3-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed |
Threaded code that uses libc_r and is based around 'poll' uses much more system CPU time than it should. Problem is tracked to a math error in the 'poll' routine. Fix: In libc_r/uthread/uthread_poll.c, we find the following suspicious math: } else if (timeout > 0) { /* Convert the timeout in msec to a timespec: */ ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000; /* Set the wake up time: */ _thread_kern_set_timeout(&ts); } else if (timeout < 0) { This conversion from milliseconds to nanoseconds is incorrect. There are a million milliseconds in a nanosecond. --- Actually, there are a million nanoseconds in a millisecond, but I get the point. =) How-To-Repeat: Run any program that calls poll in a tight loop, relying on the timeout in 'poll' to prevent a spin.