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/pcpu.h

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  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 /*
    2  * Copyright (c) 2001 Wind River Systems, Inc.
    3  * All rights reserved.
    4  * Written by: John Baldwin <jhb@FreeBSD.org>
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 4. Neither the name of the author nor the names of any co-contributors
   15  *    may be used to endorse or promote products derived from this software
   16  *    without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   28  * SUCH DAMAGE.
   29  *
   30  * $FreeBSD: src/sys/sys/pcpu.h,v 1.11 2003/11/20 22:50:26 peter Exp $
   31  */
   32 
   33 #ifndef _SYS_PCPU_H_
   34 #define _SYS_PCPU_H_
   35 
   36 #ifndef _KERNEL
   37 #error "no user-serviceable parts inside"
   38 #endif
   39 
   40 #ifdef LOCORE
   41 #error "no assembler-serviceable parts inside"
   42 #endif
   43 
   44 #include <sys/queue.h>
   45 #include <sys/vmmeter.h>
   46 #include <machine/pcpu.h>
   47 
   48 struct pcb;
   49 struct thread;
   50 
   51 /*
   52  * This structure maps out the global data that needs to be kept on a
   53  * per-cpu basis.  The members are accessed via the PCPU_GET/SET/PTR
   54  * macros defined in <machine/pcpu.h>.  Machine dependent fields are
   55  * defined in the PCPU_MD_FIELDS macro defined in <machine/pcpu.h>.
   56  */
   57 struct pcpu {
   58         struct thread   *pc_curthread;          /* Current thread */
   59         struct thread   *pc_idlethread;         /* Idle thread */
   60         struct thread   *pc_fpcurthread;        /* Fp state owner */
   61         struct thread   *pc_deadthread;         /* Zombie thread or NULL */
   62         struct pcb      *pc_curpcb;             /* Current pcb */
   63         struct bintime  pc_switchtime;  
   64         int             pc_switchticks;
   65         u_int           pc_cpuid;               /* This cpu number */
   66         u_int           pc_cpumask;             /* This cpu mask */
   67         u_int           pc_other_cpus;          /* Mask of all other cpus */
   68         SLIST_ENTRY(pcpu) pc_allcpu;
   69         struct lock_list_entry *pc_spinlocks;
   70 #ifdef KTR_PERCPU
   71         int             pc_ktr_idx;             /* Index into trace table */
   72         char            *pc_ktr_buf;
   73 #endif
   74         PCPU_MD_FIELDS;
   75         struct vmmeter  pc_cnt;                 /* VM stats counters */
   76 };
   77 
   78 SLIST_HEAD(cpuhead, pcpu);
   79 
   80 extern struct cpuhead cpuhead;
   81 
   82 #define CURPROC         (curthread->td_proc)
   83 #define curkse          (curthread->td_kse)
   84 #define curksegrp       (curthread->td_ksegrp)
   85 #define curproc         (curthread->td_proc)
   86 #ifndef curthread
   87 #define curthread       PCPU_GET(curthread)
   88 #endif
   89 
   90 /*
   91  * MI PCPU support functions
   92  *
   93  * PCPU_LAZY_INC() -    Lazily increment a per-cpu stats counter, without
   94  *                      guarenteeing atomicity or even necessarily consistency.
   95  *
   96  *                      XXX we need to create MD primitives to support
   97  *                      this to guarentee at least some level of consistency,
   98  *                      i.e., to prevent us from totally corrupting the 
   99  *                      counters due to preemption in a multi-instruction
  100  *                      increment sequence for architectures that do not
  101  *                      support single-instruction memory increments.
  102  */
  103 #define PCPU_LAZY_INC(var)      (++*PCPU_PTR(var))
  104 
  105 /*
  106  * Machine dependent callouts.  cpu_pcpu_init() is responsible for
  107  * initializing machine dependent fields of struct pcpu, and
  108  * db_show_mdpcpu() is responsible for handling machine dependent
  109  * fields for the DDB 'show pcpu' command.
  110  */
  111 void    cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size);
  112 void    db_show_mdpcpu(struct pcpu *pcpu);
  113 
  114 void    pcpu_destroy(struct pcpu *pcpu);
  115 struct  pcpu *pcpu_find(u_int cpuid);
  116 void    pcpu_init(struct pcpu *pcpu, int cpuid, size_t size);
  117 
  118 #endif /* !_SYS_PCPU_H_ */

Cache object: 08bf737bbc12276740f04da3414dbd38


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