home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / vm / mp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  2.3 KB  |  82 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. /*
  11.  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  12.  *         PROPRIETARY NOTICE (Combined)
  13.  * 
  14.  * This source code is unpublished proprietary information
  15.  * constituting, or derived under license from AT&T's UNIX(r) System V.
  16.  * In addition, portions of such source code were derived from Berkeley
  17.  * 4.3 BSD under license from the Regents of the University of
  18.  * California.
  19.  * 
  20.  * 
  21.  * 
  22.  *         Copyright Notice 
  23.  * 
  24.  * Notice of copyright on this source code product does not indicate 
  25.  * publication.
  26.  * 
  27.  *     (c) 1986,1987,1988,1989  Sun Microsystems, Inc
  28.  *     (c) 1983,1984,1985,1986,1987,1988,1989  AT&T.
  29.  *               All rights reserved.
  30.  *  
  31.  */
  32.  
  33. #ifndef _VM_MP_H
  34. #define _VM_MP_H
  35.  
  36. #ident    "@(#)/usr/include/vm/mp.h.sl 1.1 4.0 12/08/90 779 AT&T-USL"
  37.  
  38. /*
  39.  * VM - multiprocessor/ing support.
  40.  *
  41.  * Currently the mon_enter() / mon_exit() pair implements a
  42.  * simple monitor for objects protected by the appropriate lock.
  43.  * The cv_wait() / cv_broadcast pait implements a simple
  44.  * condition variable which can be used for `sleeping'
  45.  * and `waking' inside a monitor if some resource
  46.  * is needed which is not available.
  47.  */
  48.  
  49. typedef struct mon_t {
  50.     unchar    dummy;
  51. } mon_t;
  52.  
  53. #if defined(DEBUG) || defined(lint)
  54. void    mon_enter(/* lk */);
  55. void    mon_exit(/* lk */);
  56. void    cv_wait(/* lk, cond */);
  57. void    cv_broadcast(/* lk, cond */);
  58.  
  59. #else
  60.  
  61. /*
  62.  * mon_enter is used as a type of multiprocess semaphore
  63.  * used to implement a monitor where the lock represents
  64.  * the ability to operate on the associated object.
  65.  * For now, the lock/object association is done
  66.  * by convention only.
  67.  * For single processor systems that are debugged, no lock is needed.
  68.  * For multiprocessor systems that are debugged, a simple lock suffices.
  69.  * Only the single processor macros are included.
  70.  */
  71.  
  72. #define mon_enter(lk)
  73. #define mon_exit(lk)
  74. #define cv_wait(lk, cond) ((void) sleep(cond, PSWP+1))
  75. #define cv_broadcast(lk, cond) (wakeprocs(cond, PRMPT))
  76.  
  77. #endif    /* DEBUG */
  78.  
  79. #define    lock_init(lk)    (lk)->dummy = 0
  80.  
  81. #endif    /* _VM_MP_H */
  82.