disable, _disable, enable, _enable
raw OCR
Disables and enables interrupts.
Defined in header <dos.h>
Syntax
#include <dos.h>
void disable(void);
void _disable(void);
void enable(void);
void _enable(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
These macros are designed to provide a programmer with flexible hardware interrupt control.
The disable and _disable macros disable interrupts. Only the NMI (non-maskable interrupt) is allowed from any external device.
The enable and _enable macros enable interrupts, allowing any device interrupts to occur.
Return value
None.
See also
Example
/* This is an interrupt service routine. You cannot compile this program with
Test Stack Overflow turned on and get an executable file that operates
correctly. */
#include <stdio.h>
#include <dos.h>
#include <conio.h>
Mefine INTR OXlC /* The clock tick interrupt */
#ifdef cplusplus
#def ine _CPPARGS ...
#else
Mefine _CPPARGS
#endif
void interrupt (*oldhandler) {_CPPARGS) ;
int count=0;
void interrupt handler ( CPPARGS) /* if C++, need the the ellipsis */
{
/* disable interrupts during the handling of the interrupt */
_disable();
/* increase the global counter */
count++;
/* reenable interrupts at the end of the handler */
enable();
/* call the old routine */
oldhandler 0;
}
int main(void)
/* save the old interrupt vector */
oldhandler = _dos_getvect (INTR);
/* install the new interrupt handler */
_dos_setvect(INTR, handler);
/* loop until the counter exceeds 20 */
while (count < 20)
printf("count is %d\n",count);
/* reset the old interrupt handler */
_dos_setvect(INTR, oldhandler);
return
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `disable, disable, enable, enable` read as `disable, _disable, enable, _enable`
Stable link: /3.1/dos.h/disable/
· short form /3.1/disable/