summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2013-03-28 12:45:22 +0000
committer Nathan Woods <npwoods@mess.org>2013-03-28 12:45:22 +0000
commitc00f72eb4fb2d17aa43eca95ab9a225715d605d2 (patch)
tree14f1b94ffb0bf9c8df1a31370cc94fc510e9d520 /src
parentecf2facc0a3d7d13d1c41c62c69c2171c2debee3 (diff)
Minor schedule.c optimization
Diffstat (limited to 'src')
-rw-r--r--src/emu/diexec.c23
-rw-r--r--src/emu/diexec.h1
-rw-r--r--src/emu/schedule.c43
-rw-r--r--src/emu/schedule.h3
4 files changed, 51 insertions, 19 deletions
diff --git a/src/emu/diexec.c b/src/emu/diexec.c
index 2ba8a995647..2bee966bb8e 100644
--- a/src/emu/diexec.c
+++ b/src/emu/diexec.c
@@ -278,6 +278,21 @@ void device_execute_interface::set_irq_acknowledge_callback(device_irq_acknowled
m_driver_irq_legacy = NULL;
}
+
+//-------------------------------------------------
+// suspend_resume_changed
+//-------------------------------------------------
+
+void device_execute_interface::suspend_resume_changed()
+{
+ // inform the scheduler
+ device().machine().scheduler().suspend_resume_changed();
+
+ // if we're active, synchronize
+ abort_timeslice();
+}
+
+
//-------------------------------------------------
// suspend - set a suspend reason for this device
//-------------------------------------------------
@@ -288,9 +303,7 @@ if (TEMPLOG) printf("suspend %s (%X)\n", device().tag(), reason);
// set the suspend reason and eat cycles flag
m_nextsuspend |= reason;
m_nexteatcycles = eatcycles;
-
- // if we're active, synchronize
- abort_timeslice();
+ suspend_resume_changed();
}
@@ -304,9 +317,7 @@ void device_execute_interface::resume(UINT32 reason)
if (TEMPLOG) printf("resume %s (%X)\n", device().tag(), reason);
// clear the suspend reason and eat cycles flag
m_nextsuspend &= ~reason;
-
- // if we're active, synchronize
- abort_timeslice();
+ suspend_resume_changed();
}
diff --git a/src/emu/diexec.h b/src/emu/diexec.h
index e7e88ce4603..6be96c102e7 100644
--- a/src/emu/diexec.h
+++ b/src/emu/diexec.h
@@ -329,6 +329,7 @@ private:
static void static_trigger_periodic_interrupt(running_machine &machine, void *ptr, int param);
void trigger_periodic_interrupt();
+ void suspend_resume_changed();
attoseconds_t minimum_quantum() const;
};
diff --git a/src/emu/schedule.c b/src/emu/schedule.c
index 2e98b64e109..19011fcc9be 100644
--- a/src/emu/schedule.c
+++ b/src/emu/schedule.c
@@ -348,6 +348,7 @@ device_scheduler::device_scheduler(running_machine &machine) :
m_callback_timer(NULL),
m_callback_timer_modified(false),
m_callback_timer_expire_time(attotime::zero),
+ m_suspend_changes_pending(true),
m_quantum_list(machine.respool()),
m_quantum_allocator(machine.respool()),
m_quantum_minimum(ATTOSECONDS_IN_NSEC(1) / 1000)
@@ -413,6 +414,30 @@ bool device_scheduler::can_save() const
//-------------------------------------------------
+// apply_suspend_changes - applies suspend/resume
+// changes to all device_execute_interfaces
+//-------------------------------------------------
+
+inline void device_scheduler::apply_suspend_changes()
+{
+ UINT32 suspendchanged = 0;
+ for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec)
+ {
+ suspendchanged |= exec->m_suspend ^ exec->m_nextsuspend;
+ exec->m_suspend = exec->m_nextsuspend;
+ exec->m_nextsuspend &= ~SUSPEND_REASON_TIMESLICE;
+ exec->m_eatcycles = exec->m_nexteatcycles;
+ }
+
+ // recompute the execute list if any CPUs changed their suspension state
+ if (suspendchanged != 0)
+ rebuild_execute_list();
+ else
+ m_suspend_changes_pending = false;
+}
+
+
+//-------------------------------------------------
// timeslice - execute all devices for a single
// timeslice
//-------------------------------------------------
@@ -441,19 +466,9 @@ void device_scheduler::timeslice()
LOG(("------------------\n"));
LOG(("cpu_timeslice: target = %s\n", target.as_string()));
- // apply pending suspension changes
- UINT32 suspendchanged = 0;
- for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec)
- {
- suspendchanged |= exec->m_suspend ^ exec->m_nextsuspend;
- exec->m_suspend = exec->m_nextsuspend;
- exec->m_nextsuspend &= ~SUSPEND_REASON_TIMESLICE;
- exec->m_eatcycles = exec->m_nexteatcycles;
- }
-
- // recompute the execute list if any CPUs changed their suspension state
- if (suspendchanged != 0)
- rebuild_execute_list();
+ // do we have pending suspension changes?
+ if (m_suspend_changes_pending)
+ apply_suspend_changes();
// loop over non-suspended CPUs
for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec)
@@ -694,6 +709,8 @@ void device_scheduler::postload()
while ((timer = private_list.detach_head()) != NULL)
timer_list_insert(*timer);
+ m_suspend_changes_pending = true;
+
// report the timer state after a log
logerror("After resetting/reordering timers:\n");
dump_timers();
diff --git a/src/emu/schedule.h b/src/emu/schedule.h
index 8c727f60227..0910c2016e1 100644
--- a/src/emu/schedule.h
+++ b/src/emu/schedule.h
@@ -164,6 +164,7 @@ public:
void abort_timeslice();
void trigger(int trigid, attotime after = attotime::zero);
void boost_interleave(attotime timeslice_time, attotime boost_duration);
+ void suspend_resume_changed() { m_suspend_changes_pending = true; }
// timers, specified by callback/name
emu_timer *timer_alloc(timer_expired_delegate callback, void *ptr = NULL);
@@ -196,6 +197,7 @@ private:
// scheduling helpers
void compute_perfect_interleave();
void rebuild_execute_list();
+ void apply_suspend_changes();
void add_scheduling_quantum(attotime quantum, attotime duration);
// timer helpers
@@ -217,6 +219,7 @@ private:
emu_timer * m_callback_timer; // pointer to the current callback timer
bool m_callback_timer_modified; // true if the current callback timer was modified
attotime m_callback_timer_expire_time; // the original expiration time
+ bool m_suspend_changes_pending; // suspend/resume changes are pending
// scheduling quanta
class quantum_slot