mirror of
https://github.com/open-simh/simh.git
synced 2026-01-25 11:55:43 +00:00
SCP: Enhance debug output while tracking event and timer activity
This commit is contained in:
25
sim_timer.c
25
sim_timer.c
@@ -1037,6 +1037,7 @@ for (tmr=0; tmr<=SIM_NTIMERS; tmr++) {
|
||||
sim_stop_unit.action = &sim_timer_stop_svc;
|
||||
SIM_INTERNAL_UNIT.flags = UNIT_IDLE;
|
||||
sim_register_internal_device (&sim_timer_dev); /* Register Clock Assist device */
|
||||
sim_register_internal_device (&sim_throttle_dev); /* Register Throttle Device */
|
||||
sim_throttle_unit.action = &sim_throt_svc;
|
||||
sim_register_clock_unit_tmr (&SIM_INTERNAL_UNIT, SIM_INTERNAL_CLK);
|
||||
sim_idle_enab = FALSE; /* init idle off */
|
||||
@@ -1670,7 +1671,6 @@ else {
|
||||
sim_throt_wait = sim_throt_val;
|
||||
}
|
||||
}
|
||||
sim_register_internal_device (&sim_throttle_dev); /* Register Throttle Device */
|
||||
if (sim_throt_type == SIM_THROT_SPC) /* Set initial value while correct one is determined */
|
||||
sim_throt_cps = (int32)((1000.0 * sim_throt_val) / (double)sim_throt_sleep_time);
|
||||
else
|
||||
@@ -1974,7 +1974,7 @@ if ((stat == SCPE_OK) &&
|
||||
if (fabs(skew) > fabs(rtc_clock_skew_max[tmr]))
|
||||
rtc_clock_skew_max[tmr] = skew;
|
||||
}
|
||||
/* First gather the queued events that are scheduled for now */
|
||||
/* Gather any queued events which are scheduled for right now */
|
||||
do {
|
||||
cptr = sim_clock_cosched_queue[tmr];
|
||||
sim_clock_cosched_queue[tmr] = cptr->next;
|
||||
@@ -1996,11 +1996,11 @@ if ((stat == SCPE_OK) &&
|
||||
cptr->cancel = NULL;
|
||||
cptr->time = 0;
|
||||
if (cptr->usecs_remaining) {
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, " remnant: %.0f - next %s after cosched interval: %d ticks\n", cptr->usecs_remaining, (sptr != QUEUE_LIST_END) ? sim_uname (sptr) : "", sim_cosched_interval[tmr]);
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "Rescheduling %s after %.0f usecs %s%s\n", sim_uname (cptr), cptr->usecs_remaining, (sptr != QUEUE_LIST_END) ? "- next: " : "", (sptr != QUEUE_LIST_END) ? sim_uname (sptr) : "");
|
||||
sim_timer_activate_after (cptr, cptr->usecs_remaining);
|
||||
}
|
||||
else {
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, " - next %s after cosched interval: %d ticks\n", (sptr != QUEUE_LIST_END) ? sim_uname (sptr) : "", sim_cosched_interval[tmr]);
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "Activating %s now %s%s\n", sim_uname (cptr), (sptr != QUEUE_LIST_END) ? "- next: " : "", (sptr != QUEUE_LIST_END) ? sim_uname (sptr) : "");
|
||||
_sim_activate (cptr, 0);
|
||||
}
|
||||
}
|
||||
@@ -2501,12 +2501,13 @@ for (tmr=0; tmr<=SIM_NTIMERS; tmr++)
|
||||
}
|
||||
if (sim_is_active (uptr)) /* already active? */
|
||||
return SCPE_OK;
|
||||
uptr->usecs_remaining = 0;
|
||||
if (usec_delay <= 0.0) {
|
||||
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - invalid usec value\n",
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - invalid usec value\n",
|
||||
sim_uname(uptr), usec_delay);
|
||||
uptr->usecs_remaining = 0.0;
|
||||
return SCPE_ARG;
|
||||
}
|
||||
uptr->usecs_remaining = 0.0;
|
||||
/*
|
||||
* Handle long delays by aligning with the calibrated timer's calibration
|
||||
* activities. Delays which would expire prior to the next calibration
|
||||
@@ -2532,8 +2533,8 @@ if ((sim_calb_tmr != -1) && (rtc_hz[sim_calb_tmr])) { /* Calibrated Timer
|
||||
if (inst_delay_d > (double)inst_til_calib) { /* long wait? */
|
||||
stat = sim_clock_coschedule_tmr (uptr, sim_calb_tmr, ticks_til_calib - 1);
|
||||
uptr->usecs_remaining = (stat == SCPE_OK) ? usec_delay - usecs_til_calib : 0.0;
|
||||
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - coscheduling with with calibrated timer(%d), ticks=%d, usecs_remaining=%.0f usecs, inst_til_tick=%d\n",
|
||||
sim_uname(uptr), usec_delay, sim_calb_tmr, ticks_til_calib, uptr->usecs_remaining, inst_til_tick);
|
||||
sim_debug (DBG_TIM, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - coscheduling with with calibrated timer(%d), ticks=%d, usecs_remaining=%.0f usecs, inst_til_tick=%d, ticks_til_calib=%d\n",
|
||||
sim_uname(uptr), usec_delay, sim_calb_tmr, ticks_til_calib, uptr->usecs_remaining, inst_til_tick, ticks_til_calib);
|
||||
sim_debug (DBG_CHK, &sim_timer_dev, "sim_timer_activate_after(%s, %.0f usecs) - result = %.0f usecs, %.0f usecs\n",
|
||||
sim_uname(uptr), usec_delay, sim_timer_activate_time_usecs (ouptr), sim_timer_activate_time_usecs (uptr));
|
||||
return stat;
|
||||
@@ -3018,7 +3019,7 @@ if (uptr->cancel == &_sim_coschedule_cancel) {
|
||||
accum += cptr->time;
|
||||
if (cptr == uptr) {
|
||||
result = uptr->usecs_remaining + ceil(1000000.0 * ((rtc_currd[tmr] * accum) + sim_activate_time (&sim_timer_units[tmr]) - 1) / sim_timer_inst_per_sec ());
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) coscheduled - %.0f usecs, inst_per_sec=%.0f, tmr=%d, ticksize=%d, ticks=%d, inst_til_tick=%d\n", sim_uname (uptr), result, sim_timer_inst_per_sec (), tmr, rtc_currd[tmr], accum, sim_activate_time (&sim_timer_units[tmr]) - 1);
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) coscheduled - %.0f usecs, inst_per_sec=%.0f, tmr=%d, ticksize=%d, ticks=%d, inst_til_tick=%d, usecs_remaining=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec (), tmr, rtc_currd[tmr], accum, sim_activate_time (&sim_timer_units[tmr]) - 1, uptr->usecs_remaining);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -3027,17 +3028,17 @@ if (uptr->cancel == &_sim_coschedule_cancel) {
|
||||
for (tmr=0; tmr<=SIM_NTIMERS; tmr++) {
|
||||
if ((uptr == sim_clock_unit[tmr]) && (uptr->next)) {
|
||||
result = sim_clock_unit[tmr]->usecs_remaining + (1000000.0 * (sim_activate_time (&sim_timer_units[tmr]) - 1)) / sim_timer_inst_per_sec ();
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) clock - %.0f usecs, inst_per_sec=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec ());
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) clock - %.0f usecs, inst_per_sec=%.0f, usecs_remaining=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec (), uptr->usecs_remaining);
|
||||
return result;
|
||||
}
|
||||
if ((uptr == &sim_timer_units[tmr]) && (uptr->next)){
|
||||
result = uptr->usecs_remaining + (1000000.0 * (sim_activate_time (uptr) - 1)) / sim_timer_inst_per_sec ();
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) clock - %.0f usecs, inst_per_sec=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec ());
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) clock - %.0f usecs, inst_per_sec=%.0f, usecs_remaining=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec (), uptr->usecs_remaining);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result = uptr->usecs_remaining + (1000000.0 * (sim_activate_time (uptr) - 1)) / sim_timer_inst_per_sec ();
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) clock - %.0f usecs, inst_per_sec=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec ());
|
||||
sim_debug (DBG_QUE, &sim_timer_dev, "sim_timer_activate_time_usecs(%s) clock - %.0f usecs, inst_per_sec=%.0f, usecs_remaining=%.0f\n", sim_uname (uptr), result, sim_timer_inst_per_sec (), uptr->usecs_remaining);
|
||||
return result; /* Not found. */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user