Fixed sim_idle to account for a reasonable number of cycles which have passed when an asynchrnous event terminated the idle wait.

Also corrected the text of a printf which described the units of the asynch latency variable as nano seconds instead of microseconds.
This commit is contained in:
Mark Pizzolato 2011-04-22 05:47:26 -07:00
parent 049540aa20
commit f7b53a5fe9
2 changed files with 8 additions and 1 deletions

2
scp.c
View file

@ -1823,7 +1823,7 @@ else {
fprintf (st, " event delay %d, queue time %d\n", uptr->a_event_time, uptr->a_sim_interval);
}
}
fprintf (st, "asynch latency: %d microseconds\n", sim_asynch_latency);
fprintf (st, "asynch latency: %d nanoseconds\n", sim_asynch_latency);
fprintf (st, "asynch instruction latency: %d instructions\n", sim_asynch_inst_latency);
pthread_mutex_unlock (&sim_asynch_lock);
#endif

View file

@ -23,6 +23,8 @@
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
22-Apr-11 MP Fixed Asynch I/O support to reasonably account cycles
when an idle wait is terminated by an external event
05-Jan-11 MP Added Asynch I/O support
29-Dec-10 MP Fixed clock resolution determination for Unix platforms
22-Sep-08 RMS Added "stability threshold" for idle routine
@ -44,6 +46,9 @@
sim_os_msec - return elapsed time in msec
sim_os_sleep - sleep specified number of seconds
sim_os_ms_sleep - sleep specified number of milliseconds
sim_idle_ms_sleep - sleep specified number of milliseconds
or until awakened by an asynchronous
event
The calibration, idle, and throttle routines are OS-independent; the _os_
routines are not.
@ -576,6 +581,8 @@ if (w_idle == 0) { /* none? */
}
act_ms = SIM_IDLE_MS_SLEEP (w_ms); /* wait */
act_cyc = act_ms * cyc_ms;
if (act_ms < w_ms) /* awakened early? */
act_cyc += (cyc_ms * sim_idle_rate_ms) / 2; /* account for half an interval's worth of cycles */
if (sim_interval > act_cyc)
sim_interval = sim_interval - act_cyc;
else sim_interval = 0;