DOC

disable

By Tom Reed,2014-08-27 18:39
13 views 0
disable

函数名: disable

     : 屏蔽中断

     : #include <dos.h>

     void disable(void);

    程序例:

    /***NOTE: 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>

    #define INTR 0X1C /* The clock tick

     interrupt */

    void interrupt ( *oldhandler)(void); int count=0;

    void interrupt handler(void)

    {

    /* 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();

    }

    int main(void)

    {

    /* save the old interrupt vector */

     oldhandler = getvect(INTR); /* install the new interrupt handler */

     setvect(INTR, handler);

    /* loop until the counter exceeds 20 */

     while (count < 20)

     printf("count is %d\n",count); /* reset the old interrupt handler */

     setvect(INTR, oldhandler);

     return 0;

    }

     返回

Report this document

For any questions or suggestions please email
cust-service@docsford.com