schedule.c: make yield() actually yield again, rather than be a synonym for spin() [Alex Jackson]

This commit is contained in:
Alex W. Jackson 2014-07-04 12:26:09 +00:00
parent c96e0ca32a
commit 4c148ffb50

View File

@ -415,7 +415,7 @@ void device_scheduler::timeslice()
bool call_debugger = ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0); bool call_debugger = ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0);
// build the execution list if we don't have one yet // build the execution list if we don't have one yet
if (m_execute_list == NULL) if (UNEXPECTED(m_execute_list == NULL))
rebuild_execute_list(); rebuild_execute_list();
// if the current quantum has expired, find a new one // if the current quantum has expired, find a new one
@ -439,11 +439,12 @@ void device_scheduler::timeslice()
if (m_suspend_changes_pending) if (m_suspend_changes_pending)
apply_suspend_changes(); apply_suspend_changes();
// loop over non-suspended CPUs // loop over all CPUs
for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec)
{ {
// only process if our target is later than the CPU's current time (coarse check) // only process if this CPU is executing or truly halted (not yielding)
if (target.seconds >= exec->m_localtime.seconds) // and if our target is later than the CPU's current time (coarse check)
if (EXPECTED((exec->m_suspend == 0 || exec->m_eatcycles) && target.seconds >= exec->m_localtime.seconds))
{ {
// compute how many attoseconds to execute this CPU // compute how many attoseconds to execute this CPU
attoseconds_t delta = target.attoseconds - exec->m_localtime.attoseconds; attoseconds_t delta = target.attoseconds - exec->m_localtime.attoseconds;