The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/lock.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: lock.h,v 1.83 2008/04/28 20:24:10 martin Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1999, 2000, 2006, 2007 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center, by Ross Harvey, and by Andrew Doran.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30  * POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1995
   35  *      The Regents of the University of California.  All rights reserved.
   36  *
   37  * This code contains ideas from software contributed to Berkeley by
   38  * Avadis Tevanian, Jr., Michael Wayne Young, and the Mach Operating
   39  * System project at Carnegie-Mellon University.
   40  *
   41  * Redistribution and use in source and binary forms, with or without
   42  * modification, are permitted provided that the following conditions
   43  * are met:
   44  * 1. Redistributions of source code must retain the above copyright
   45  *    notice, this list of conditions and the following disclaimer.
   46  * 2. Redistributions in binary form must reproduce the above copyright
   47  *    notice, this list of conditions and the following disclaimer in the
   48  *    documentation and/or other materials provided with the distribution.
   49  * 3. Neither the name of the University nor the names of its contributors
   50  *    may be used to endorse or promote products derived from this software
   51  *    without specific prior written permission.
   52  *
   53  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   54  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   56  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   63  * SUCH DAMAGE.
   64  *
   65  *      @(#)lock.h      8.12 (Berkeley) 5/19/95
   66  */
   67 
   68 #ifndef _SYS_LOCK_H_
   69 #define _SYS_LOCK_H_
   70 
   71 #include <sys/stdint.h>
   72 #include <sys/mutex.h>
   73 
   74 #include <machine/lock.h>
   75 
   76 #define LK_TYPE_MASK    0x0000000f      /* type of lock sought */
   77 #define LK_SHARED       0x00000001      /* shared lock */
   78 #define LK_EXCLUSIVE    0x00000002      /* exclusive lock */
   79 #define LK_RELEASE      0x00000006      /* release any type of lock */
   80 #define LK_EXCLOTHER    0x00000008      /* other process holds lock */
   81 
   82 #define LK_NOWAIT       0x00000010      /* do not sleep to await lock */
   83 #define LK_CANRECURSE   0x00000040      /* this may be recursive lock attempt */
   84 #define LK_INTERLOCK    0x00010000      /* unlock passed simple lock after
   85                                            getting lk_interlock */
   86 #define LK_RETRY        0x00020000      /* vn_lock: retry until locked */
   87 
   88 #ifdef _KERNEL
   89 
   90 /*
   91  * From <machine/lock.h>.
   92  */
   93 #ifndef SPINLOCK_SPIN_HOOK
   94 #define SPINLOCK_SPIN_HOOK
   95 #endif
   96 #ifndef SPINLOCK_BACKOFF_HOOK
   97 #define SPINLOCK_BACKOFF_HOOK           nullop(NULL)
   98 #endif
   99 #ifndef SPINLOCK_BACKOFF_MIN
  100 #define SPINLOCK_BACKOFF_MIN    4
  101 #endif
  102 #ifndef SPINLOCK_BACKOFF_MAX
  103 #define SPINLOCK_BACKOFF_MAX    128
  104 #endif
  105 
  106 #define SPINLOCK_BACKOFF(count)                                 \
  107 do {                                                            \
  108         int __i;                                                \
  109         for (__i = (count); __i != 0; __i--) {                  \
  110                 SPINLOCK_BACKOFF_HOOK;                          \
  111         }                                                       \
  112         if ((count) < SPINLOCK_BACKOFF_MAX)                     \
  113                 (count) += (count);                             \
  114 } while (/* CONSTCOND */ 0);
  115 
  116 #define SPINLOCK_RUN_HOOK(count)        ((count) >= SPINLOCK_BACKOFF_MAX)
  117 
  118 #ifdef LOCKDEBUG
  119 #define SPINLOCK_SPINOUT(spins)         ((spins)++ > 0x0fffffff)
  120 #else
  121 #define SPINLOCK_SPINOUT(spins)         ((void)(spins), 0)
  122 #endif
  123 
  124 extern __cpu_simple_lock_t kernel_lock[];
  125 
  126 #endif /* _KERNEL */
  127 
  128 #endif /* _SYS_LOCK_H_ */

Cache object: 01a88ef2706cde0a63c60df126a304ee


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.