mamedev / mame

MAME
https://www.mamedev.org/
Other
7.95k stars 1.98k forks source link

Fix slot cards that were relying on setting perfect quantum device #5838

Open cuavas opened 4 years ago

cuavas commented 4 years ago

Some slot card devices were setting perfect quantum devices. This is problematic because it's a global setting for a machine configuration. If the slot card is loaded in a system that wants to set it for a device with faster timings, it would override it causing problems. These devices need to be fixed.

The simple/lazy way to fix them is to just set an equivalent maximum quantum time – this works for multiple devices in a system, the scheduler will just choose the smallest (most restrictive) one. A better way is to add appropriate barriers to make it work.

The affected classes are (with source files and copyright holders):

happppp commented 4 years ago

I'm surprised perfect_quantum override isn't used in more places. Anyway, add a barrier where? Do something like: if (perfect_quantum_wasnt_set) { set perfect quantum } Then it would go wrong if device A set perfect quantum on a 1MHz CPU, and device B afterwards wants to set it on a 20MHz CPU.

or: if (my_quantum < global_quantum) { set perfect quantum } Then in theory it could still go wrong when CPU clock is changed later on.

cuavas commented 4 years ago

No, add a barrier as in put a synchronisation barrier on the operation that requires synchronisation to work (e.g. a timer or a call to synchronize on the scheduler). Devices can't set perfect quantum device as it's a global, and it will now cause a fatal error. If synchronisation barriers are too hard, use config.set_maximum_quantum with a number that works.

happppp commented 4 years ago

c64_final_chesscard_device works fine(I tested it with daily build), the perfect quantum was added for safety. All inter-cpu comms are via gen_latch and that device is synchronized.

cuavas commented 4 years ago

Cool, I'll remove the fixme on my next commit for that one.