[Previous]
[Contents]
[Next]

_disable()

disable interrupts

Synopsis:

#include <i86.h>
void _disable( void );

Description:

The _disable() function causes interrupts to become disabled.

The _disable() function is used in conjunction with the _enable function to make sure that a sequence of instructions is executed without any intervening interruptions.

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <i86.h>

struct list_entry {
    struct list_entry *next;
    int    data;
};
struct list_entry *ListHead = NULL;
struct list_entry *ListTail = NULL;

void insert( struct list_entry *new_entry )
  {
    /* insert new_entry at end of linked list */
    new_entry->next = NULL;
    _disable();      /* disable interrupts */
    if( ListTail == NULL ) {
      ListHead = new_entry;
    } else {
      ListTail->next = new_entry;
    }
    ListTail = new_entry;
    _enable();       /* enable interrupts now */
  }

void main()
  {
    struct list_entry *p;
    int i;

    for( i = 1; i <= 10; i++ ) {
      p = (struct list_entry *)
          malloc( sizeof( struct list_entry ) );
      if( p == NULL ) break;
      p->data = i;
      insert( p );
    }
  }

Classification:

Intel

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

When you use the _disable() function, your program must be linked for privity level 1, and the process must be run by the superuser (root). For more information on privity, see

See also:

_enable()


[Previous]
[Contents]
[Next]