The VID_IRET_Proc procedure can be used to help prevent stack overflows when an interrupt routine in a virtual machine attempts to process too many simulated interrupts. Consider the following interrupt routine, a routine that is very common in actual terminal applications:
push ax ; push AX, DX is the push dx ; minimum possible . . ; read a byte from the COM port . mov al, 20h ; non-specific EOI out 20h, al ; EOI the PIC sti ; enable interrupts . . ; do other stuff . pop dx pop ax iret
In this routine, if an interrupt occurs after the sti but before the iret instruction, control re-enters the interrupt routine and the amount of data on the stack grows by 10 bytes (6 bytes for the return address and 4 bytes for the saved AX and DX registers). Since the virtual communications device (VCD) may queue hundreds of bytes of data before the virtual machine begins processing simulated interrupts, this interrupt routine can potentially be re-entered hundreds of times (requiring several kilobytes of stack space) unless the VCD delays its request for the next simulated interrupt until after the iret instruction is executed. Installing the VID_IRET_Proc procedure lets the VCD delay the request, preventing the interrupt routine from being re-entered.
The virtual timer device uses similar logic to prevent sending too many timer interrupts to a virtual machine.