Bug 16245

Summary: poll misconverts milliseconds to nanoseconds
Product: Base System Reporter: davids <davids>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.3-STABLE   
Hardware: Any   
OS: Any   

Description davids 2000-01-21 08:10:01 UTC
	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.
Comment 1 Jason Evans freebsd_committer freebsd_triage 2000-01-22 09:09:41 UTC
State Changed
From-To: open->closed