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/i386/include/critical.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2002 Matthew Dillon.  All Rights Reserved.
    3  * Redistribution and use in source and binary forms, with or without
    4  * modification, are permitted provided that the following conditions
    5  * are met:
    6  * 1. Redistributions of source code must retain the above copyright
    7  *    notice, this list of conditions and the following disclaimer.
    8  * 2. Redistributions in binary form must reproduce the above copyright
    9  *    notice, this list of conditions and the following disclaimer in the
   10  *    documentation and/or other materials provided with the distribution.
   11  * 4. Neither the name of the University nor the names of its contributors
   12  *    may be used to endorse or promote products derived from this software
   13  *    without specific prior written permission.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   16  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   24  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  *
   27  * This file contains prototypes and high-level inlines related to
   28  * machine-level critical function support:
   29  *
   30  *      cpu_critical_enter()            - inlined
   31  *      cpu_critical_exit()             - inlined
   32  *      cpu_critical_fork_exit()        - prototyped
   33  *      related support functions residing
   34  *      in <arch>/<arch>/critical.c     - prototyped
   35  *
   36  * $FreeBSD: src/sys/i386/include/critical.h,v 1.8 2004/07/27 16:41:01 rwatson Exp $
   37  */
   38 
   39 #ifndef _MACHINE_CRITICAL_H_
   40 #define _MACHINE_CRITICAL_H_
   41 
   42 __BEGIN_DECLS
   43 
   44 /*
   45  * Prototypes - see <arch>/<arch>/critical.c
   46  */
   47 void cpu_critical_fork_exit(void);
   48 
   49 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
   50 
   51 /*
   52  *      cpu_critical_enter:
   53  *
   54  *      This routine is called from critical_enter() on the 0->1 transition
   55  *      of td_critnest, prior to it being incremented to 1.
   56  *
   57  *      If new-style critical section handling we do not have to do anything.
   58  *      However, as a side effect any interrupts occuring while td_critnest
   59  *      is non-zero will be deferred.
   60  */
   61 static __inline void
   62 cpu_critical_enter(struct thread *td)
   63 {
   64         td->td_md.md_savecrit = intr_disable();
   65 }
   66 
   67 /*
   68  *      cpu_critical_exit:
   69  *
   70  *      This routine is called from critical_exit() on a 1->0 transition
   71  *      of td_critnest, after it has been decremented to 0.  We are
   72  *      exiting the last critical section.
   73  *
   74  *      Note that the td->critnest (1->0) transition interrupt race against
   75  *      our int_pending/unpend() check below is handled by the interrupt
   76  *      code for us, so we do not have to do anything fancy.
   77  */
   78 static __inline void
   79 cpu_critical_exit(struct thread *td)
   80 {
   81         intr_restore(td->td_md.md_savecrit);
   82 }
   83 
   84 #else /* !(__GNUC__ || __INTEL_COMPILER) */
   85 
   86 void cpu_critical_enter(struct thread *td);
   87 void cpu_critical_exit(struct thread *td);
   88 
   89 #endif        /* __GNUC__ || __INTEL_COMPILER */
   90 
   91 __END_DECLS
   92 
   93 #endif /* !_MACHINE_CRITICAL_H_ */
   94 

Cache object: 635d7aa121a613013f85272753dee4c9


[ 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.