home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / lan / soss.arj / INCLUDE / NETQ.H < prev    next >
C/C++ Source or Header  |  1991-04-11  |  1KB  |  31 lines

  1. /* Copyright 1986 by Carnegie Mellon */
  2. /*  Copyright 1983 by the Massachusetts Institute of Technology  */
  3.  
  4. #ifndef NETQ_H            /* DDP */
  5. #define NETQ_H    1        /* DDP */
  6.  
  7. #include <q.h>
  8.  
  9. extern queue freeq;        /* The queue of unused packets */
  10.  
  11. /* Getting packets from the queue of received packets is an operation that is
  12.     used at non-interrupt level, but the queue is modified at interrupt,
  13.     so the operation must be atomic. On the other hand, adding a packet to
  14.     this queue is only done at interrupt level, and thus cannot be further
  15.     interrupted. This operation, then, does not need to be atomic.
  16.        However, both of the free queue operations need to be atomic because
  17.     packets    can be allocated from interrupt level or from high level
  18.     routines. But the interrupt level routines shouldn't have interrupts
  19.     reenabled accidentally, so they have to have a nonatomic operation for
  20.     getting a packet. Hence GETFREE and A_GETFREE. A_GETFREE should be used
  21.     from high level routines; GETFREE from interrupt level routines. */
  22.  
  23.  
  24. #define    putfree(p)    { p->nb_prot = p->nb_buff+MaxLnh; \
  25.                 aq_addt(&freeq, (q_elt)p); }
  26.  
  27. #define    getfree()    (PACKET)q_deq(&freeq)
  28.  
  29. #define    a_getfree()    (PACKET)aq_deq(&freeq)
  30. #endif                /* DDP */
  31.