High CPU Utilization on Linux Server due to select/poll calls

Some times we encounter High CPU utilization by our processes which using select/poll calls on Linux server. 

Solution : Timeout will be left with time left which is not slept.

Please note there is no corruption here with struct tv(time variable).

Behavior of select call on Linux machines:
On Linux, select () modifies timeout to reflect the amount of time not slept; most other implementations do not do this. (POSIX.1-2001 permits either behavior.)
This causes problems both when Linux code which reads timeout is ported to other operating systems, and when code is ported to Linux that reuses a struct timeval for multiple select()s in a loop without reinitializing it.

I re-assigned tv.sec and tv.usec every time I call on select () call in a while loop, so that this value even gets to zero and will reassigned with the initial value supposed to be there.


tv.tv_sec = 5;
    tv.tv_usec = 0;

    retval = select(1, &rfds, NULL, NULL, &tv);
On Linux machines its highly recommended to use pselect() [Posix standard] call and the difference is ‘select() may update the timeout argument to indicate how much time was left. pselect() does not change this argument’.