breiter -> select(2) ignoring timeval argument (Mar. 11, '06, 9:37:02 PM) |
When I upgraded to SUA/Interix 5.2, I installed xgalaga. Which is frivolous, I know. The thing is that it works fine on SFU/Interix 3.5 but runs crazy-fast on SUA/Interix 5.2. The entire thing is a blur.
I pinged Rodney on this and he mentioned that xgalaga uses select(2) to throttle its speed. Thinking maybe I just needed to change the timing, I downloaded grabbed the xgalaga source code. Building it myself didn't help. I looked at documentation of select(2).
From man 2 select:
If timeout is a non-nil pointer, it specifies a maximum interval to wait
for the selection to complete. If timeout is a nil pointer, the select
blocks indefinitely. To effect a poll, the timeout argument should be non-
nil, pointing to a zero-valued timeval structure.
I injected this code at the end of the while(1) loop.
//insert a 10 second pause on every loop to test select().
struct timeval pause;
gettimeofday(&pause, 0);
printf("Get pause time: %d\n", pause.tv_sec);
pause.tv_sec += 10L;
printf("Add 10 seconds: %d\n", pause.tv_sec);
(void) select(0, 0, 0, 0, &pause);
This is the kind of output I get while xgalaga is running.
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
No pause happened when select was called, so we're on the same second when the next loop iteration comes around. I think there is something very wrong here. Select(2) seems to be ignoring the timeval pause. |
|
|
|