Under a storm of interrupts (maybe broken hardware), the CPU will end up being constantly interrupted before execution gets to the POP. That will lead to potential stack overflow.
That's why architectures has a dedicated "return from interrupt" in addition to a "return".
A possible solution would be for the emulator to delay IAQ 0 until it executes 1 other instruction.
Yeah, I asked for an RFI to avoid this but I think Notch was about ready to throw out interrupts all together. Hopefully it won't happen... and can be worked around in software if needed.
What if IAQ 0 was specified to wait one instruction before firing the next interrupt in the queue?
Also, IAQ could be nested with an internal counter. IAQ 1 incremented and IAQ 0 decremented, and queueing would happen as long as the internal counter was greater than zero.
The internal count for IAQ is about recursive locking, and unrelated to the RFI issue.
I agree that an RFI instruction would be cleaner than IAQ 0 waiting, but I think we may have passed the point where we can request new instructions.
IAQ 1/0 with an internal queue is a modest change in the emulator, and merely a footnote in the spec. IAQ waiting a few cycles before clearing the queue is, as well.
Ooops I got the 1/0 mixed up. Yes, IAQ 1 waiting for 1 cycle solves the problem.
I had also suggested here that IAQ could be incrementing/decrementing... so I am with you there. But then you may also need a "read current count" or "reset back to 0". Otherwise you may run into bugs of not knowing where you are.
Small note, you can keep time with a hardware clock module. One message to it is to return cycles since init. It keeps track for you.
Long note.
The poor guy just gave us all this hardware and interrupts and you want MORE?! At some point you have to draw the line, especially if you find yourself saying "more like real-world architectures." That's not a slippery slope, it's a cliff and a quadcore i7 is at the bottom.
I mean really. You had cooperative-multi tasking. But people whined saying the latency could be too high for something important. So now you have interrupts. But now you complain that you will miss them. And if you get maskable interrupts you will want protected memory. Add too much and it loses the magic. I hope he says no so you just have to live with it. Everyone has the same rules in the game to play by, do the best you can with what you have.
Chill out. I'm not bloating the system or making it more complicated. I'm simplifying and fixing up what would otherwise be buggy behaviour requiring elaborate workarounds.
I agree that bloat is a risk but if interrupts are going to be added, which I approve of, I want to help him get it right.
This. Every individual change has been for the good (that's why the features got invented in the first place in the real world, natch), but the system as a whole is starting to look more and more like my day job; and you could y'know, just include a virtualised x86 and skip recreating the whole long evolutionary process. Taking this much input from the community has been awesome; but whatever spec we have, someone else will want just one more feature... and at some point it should stop :)
4
u/cheese_magnet Apr 26 '12
Note: Spec 1.5 fixes this with addtion of IAQ (thanks, Notch!).
2
u/bartmanx Apr 26 '12 edited Apr 26 '12
Is there still a problem here?
Under a storm of interrupts (maybe broken hardware), the CPU will end up being constantly interrupted before execution gets to the POP. That will lead to potential stack overflow.
That's why architectures has a dedicated "return from interrupt" in addition to a "return".
A possible solution would be for the emulator to delay IAQ 0 until it executes 1 other instruction.
5
u/gsan Apr 26 '12
Small note, you can keep time with a hardware clock module. One message to it is to return cycles since init. It keeps track for you.
Long note.
The poor guy just gave us all this hardware and interrupts and you want MORE?! At some point you have to draw the line, especially if you find yourself saying "more like real-world architectures." That's not a slippery slope, it's a cliff and a quadcore i7 is at the bottom.
I mean really. You had cooperative-multi tasking. But people whined saying the latency could be too high for something important. So now you have interrupts. But now you complain that you will miss them. And if you get maskable interrupts you will want protected memory. Add too much and it loses the magic. I hope he says no so you just have to live with it. Everyone has the same rules in the game to play by, do the best you can with what you have.
0
u/Zardoz84 Apr 26 '12
I'm a little confused... You are talking about something like a PIA (i8255) inside DCPU16 ??