mirror of
https://github.com/holub/mame
synced 2025-05-31 18:11:50 +03:00
Fix scheduler overflow when a device executes for more cycles than there are in a second
This commit is contained in:
parent
2ea5c18289
commit
3387442694
@ -498,7 +498,15 @@ void device_scheduler::timeslice()
|
||||
exec->m_totalcycles += ran;
|
||||
|
||||
// update the local time for this CPU
|
||||
attotime deltatime(0, exec->m_attoseconds_per_cycle * ran);
|
||||
attotime deltatime;
|
||||
if (ran < exec->m_cycles_per_second)
|
||||
deltatime = attotime(0, exec->m_attoseconds_per_cycle * ran);
|
||||
else
|
||||
{
|
||||
u32 remainder;
|
||||
s32 secs = divu_64x32_rem(ran, exec->m_cycles_per_second, &remainder);
|
||||
deltatime = attotime(secs, u64(remainder) * exec->m_attoseconds_per_cycle);
|
||||
}
|
||||
assert(deltatime >= attotime::zero);
|
||||
exec->m_localtime += deltatime;
|
||||
LOG((" %d ran, %d total, time = %s\n", ran, s32(exec->m_totalcycles), exec->m_localtime.as_string(PRECISION)));
|
||||
|
Loading…
Reference in New Issue
Block a user