Detecting Idle Time in Windows

Last reviewed: July 23, 1997
Article ID: Q96422
3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1

SUMMARY

When the system goes idle under Microsoft Windows version 3.1, Kernel issues a single Interrupt 2Fh function 1689h call. This interrupt can be used by a Windows-based application to detect idle time.

MORE INFORMATION

Listed as "Windows kernel idle call" in the INT2FAPI.INC file of the Windows Device Development Kit (DDK) version 3.1, Interrupt 2Fh function 1689h is the system-idle notification. To be notified when the system becomes idle, a Windows-based application must put an interrupt service routine (ISR) in the Interrupt 2Fh chain using the MS-DOS Set Interrupt Vector call (Interrupt 21h function 25h), and look for AX register equal to 1689h. The ISR must call the address of the old handler to pass the control down the Interrupt 2Fh chain. The address of the old handler can be retrieved using the MS-DOS Get Interrupt Vector call (Interrupt 21h function 35h).

The ISR must be part of a device driver, dynamic-link library (DLL), or installable device driver. Furthermore, the ISR is required to be in a fixed segment. This can be accomplished by marking the segment of the ISR as PRELOAD FIXED in the module definition (.DEF) file for the DLL.

Hooking Interrupt 2Fh function 1689h to detect idle time can result in performance degradation. Therefore, if a Windows-based application only needs to perform background processing, it must use the PeekMessage() and WaitMessage() functions. Only those applications that need to detect idle time (for example, benchmarking applications) should use Interrupt 2Fh.


Additional reference words: 3.10
KBCategory: kbprg
KBSubcategory: KrMisc
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.