I’m currently building a small virtual machine in c modelling an old 16-bit CPU, which runs at a super slow clock speed (a few 100 Khz). How would I throttle the virtual machine’s processing speed of opcode, etc..? or would I even want to?
Share
As I said in the comments I suggest using some sort of timer mechanism
if you would like to match a certain speed here is how I would do it:
which means every second 1000 operations are occurring, so take the reciprocal to find the amount of time in between operations so 1/1000 s or 1 ms
So lets say you want to match 125 kHz
so 1/125000 s or .008 ms or 8000 ns
Hope this helps!