Interrupt 28h MS-DOS Idle Handler

MS-DOS Idle Handler (Interrupt 28h) carries out background operations, such as printing from a queue, while the system waits for user input. MS-DOS issues this interrupt while waiting for completion of character I/O functions (Interrupt 21h Functions 01h through 0Ch).

Programs that are idle (for example, programs that are polling for user input) can issue Interrupt 28h. Programs should also issue MS-DOS Idle Call (Interrupt 2Fh Function 1680h).

Comments

MS-DOS provides a minimal MS-DOS idle handler that returns immediately. System commands, such as print, install their own handlers to carry out background processing. Although other programs can install MS-DOS idle handlers, these programs must take great care to prevent corrupting internal stacks and registers.

MS-DOS issues Interrupt 28h only if a character I/O function has not yet completed, but does not issue the interrupt if a critical-error handler is currently running (that is, the ErrorMode internal variable is not zero). MS-DOS issues the interrupt each time it loops through a low-level read or write operation, and continues to issue the interrupt until a character is read or written.

Programs that install an MS-DOS idle handler should create a chain of handlers—that is, save the original address from the Interrupt 28h vector-table entry and call the address as part of processing.

MS-DOS makes few preparations before issuing Interrupt 28h. When control transfers to the MS-DOS idle handler, segment registers point to internal MS-DOS data segments. The SS:SP registers point to the top of the MS-DOS internal I/O stack. To prevent corrupting the system data and stack, the MS-DOS idle handler must switch to its own stack, preserve all registers, and set segment registers to point to its own data segments.

Although the MS-DOS idle handler can call system functions, it must not call character I/O functions (Interrupt 21h Functions 01h through 0Ch) without first setting the ErrorMode variable to 1. If the handler calls these functions without setting ErrorMode, the call will corrupt the internal I/O stack and MS-DOS operation.

Before returning to the system, the MS-DOS idle handler must restore the SS:SP registers to point to the I/O stack, restore all registers, and set the ErrorMode variable to zero.

See Also

Interrupt 2Fh Function 1680h MS-DOS Idle Call