trunk/src/emu/schedule.c
| r31239 | r31240 | |
| 19 | 19 | #define VERBOSE 0 |
| 20 | 20 | |
| 21 | 21 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 22 | #define PRECISION |
| 22 | 23 | |
| 23 | 24 | |
| 24 | 25 | |
| r31239 | r31240 | |
| 292 | 293 | |
| 293 | 294 | void emu_timer::dump() const |
| 294 | 295 | { |
| 295 | | logerror("%p: en=%d temp=%d exp=%15s start=%15s per=%15s param=%d ptr=%p", this, m_enabled, m_temporary, m_expire.as_string(), m_start.as_string(), m_period.as_string(), m_param, m_ptr); |
| 296 | logerror("%p: en=%d temp=%d exp=%15s start=%15s per=%15s param=%d ptr=%p", this, m_enabled, m_temporary, m_expire.as_string(PRECISION), m_start.as_string(PRECISION), m_period.as_string(PRECISION), m_param, m_ptr); |
| 296 | 297 | if (m_device == NULL) |
| 297 | 298 | logerror(" cb=%s\n", m_callback.name()); |
| 298 | 299 | else |
| r31239 | r31240 | |
| 433 | 434 | target = m_timer_list->m_expire; |
| 434 | 435 | |
| 435 | 436 | LOG(("------------------\n")); |
| 436 | | LOG(("cpu_timeslice: target = %s\n", target.as_string())); |
| 437 | LOG(("cpu_timeslice: target = %s\n", target.as_string(PRECISION))); |
| 437 | 438 | |
| 438 | 439 | // do we have pending suspension changes? |
| 439 | 440 | if (m_suspend_changes_pending) |
| r31239 | r31240 | |
| 459 | 460 | { |
| 460 | 461 | // compute how many cycles we want to execute |
| 461 | 462 | int ran = exec->m_cycles_running = divu_64x32((UINT64)delta >> exec->m_divshift, exec->m_divisor); |
| 462 | | LOG((" cpu '%s': %d cycles\n", exec->device().tag(), exec->m_cycles_running)); |
| 463 | LOG((" cpu '%s': %"I64FMT"d (%d cycles)\n", exec->device().tag(), delta, exec->m_cycles_running)); |
| 463 | 464 | |
| 464 | 465 | // if we're not suspended, actually execute |
| 465 | 466 | if (exec->m_suspend == 0) |
| r31239 | r31240 | |
| 495 | 496 | attotime delta = attotime(0, exec->m_attoseconds_per_cycle * ran); |
| 496 | 497 | assert(delta >= attotime::zero); |
| 497 | 498 | exec->m_localtime += delta; |
| 498 | | LOG((" %d ran, %d total, time = %s\n", ran, (INT32)exec->m_totalcycles, exec->m_localtime.as_string())); |
| 499 | LOG((" %d ran, %d total, time = %s\n", ran, (INT32)exec->m_totalcycles, exec->m_localtime.as_string(PRECISION))); |
| 499 | 500 | |
| 500 | 501 | // if the new local CPU time is less than our target, move the target up, but not before the base |
| 501 | 502 | if (exec->m_localtime < target) |
| r31239 | r31240 | |
| 874 | 875 | |
| 875 | 876 | inline void device_scheduler::execute_timers() |
| 876 | 877 | { |
| 877 | | LOG(("execute_timers: new=%s head->expire=%s\n", m_basetime.as_string(), m_timer_list->m_expire.as_string())); |
| 878 | LOG(("execute_timers: new=%s head->expire=%s\n", m_basetime.as_string(PRECISION), m_timer_list->m_expire.as_string(PRECISION))); |
| 878 | 879 | |
| 879 | 880 | // now process any timers that are overdue |
| 880 | 881 | while (m_timer_list->m_expire <= m_basetime) |
| r31239 | r31240 | |
| 897 | 898 | |
| 898 | 899 | if (timer.m_device != NULL) |
| 899 | 900 | { |
| 900 | | LOG(("execute_timers: timer device %s timer %d\n", timer.m_device->name(), timer.m_id)); |
| 901 | LOG(("execute_timers: timer device %s timer %d\n", timer.m_device->tag(), timer.m_id)); |
| 901 | 902 | timer.m_device->timer_expired(timer, timer.m_id, timer.m_param, timer.m_ptr); |
| 902 | 903 | } |
| 903 | 904 | else if (!timer.m_callback.isnull()) |
| r31239 | r31240 | |
| 978 | 979 | void device_scheduler::dump_timers() const |
| 979 | 980 | { |
| 980 | 981 | logerror("=============================================\n"); |
| 981 | | logerror("Timer Dump: Time = %15s\n", time().as_string()); |
| 982 | logerror("Timer Dump: Time = %15s\n", time().as_string(PRECISION)); |
| 982 | 983 | for (emu_timer *timer = first_timer(); timer != NULL; timer = timer->next()) |
| 983 | 984 | timer->dump(); |
| 984 | 985 | logerror("=============================================\n"); |