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/mach/profil.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  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 
   27 /*
   28  * Copyright 1991 by Open Software Foundation,
   29  * Grenoble, FRANCE
   30  *
   31  *              All Rights Reserved
   32  * 
   33  *   Permission to use, copy, modify, and distribute this software and
   34  * its documentation for any purpose and without fee is hereby granted,
   35  * provided that the above copyright notice appears in all copies and
   36  * that both the copyright notice and this permission notice appear in
   37  * supporting documentation, and that the name of OSF or Open Software
   38  * Foundation not be used in advertising or publicity pertaining to
   39  * distribution of the software without specific, written prior
   40  * permission.
   41  * 
   42  *   OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
   43  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
   44  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
   45  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
   46  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
   47  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
   48  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   49  */
   50 
   51 /*
   52  * HISTORY
   53  * $Log:        profil.h,v $
   54  * Revision 2.2  93/01/14  17:46:39  danner
   55  *      Standardized include symbol name.
   56  *      [92/06/10            pds]
   57  * 
   58  * Revision 2.1  91/09/26  04:49:20  bernadat
   59  * Created.
   60  * 
   61  * Data structures and macros used for the  profiling service.
   62  * (Bernard Tabib & Andrei Danes @ gr.osf.org)
   63  */
   64 
   65 #ifndef _MACH_PROFIL_H_
   66 #define _MACH_PROFIL_H_
   67 
   68 #include <mach/boolean.h>
   69 #include <ipc/ipc_object.h>
   70 #include <vm/vm_kern.h> 
   71 
   72 
   73 #define NB_PROF_BUFFER          2       /* number of buffers servicing a 
   74                                          * profiled thread */
   75 #define SIZE_PROF_BUFFER        100     /* size of a profil buffer (in int) 
   76                                          * This values is also defined in
   77                                          * the server (ugly), be careful ! */
   78 
   79 
   80 struct  prof_data {
   81         ipc_object_t    prof_port;      /* where to send a full buffer */
   82 
   83         struct buffer {
   84             int *p_zone;                /* points to the actual storage area */
   85             int                 p_index;/* next slot to be filled */
   86             boolean_t           p_full; /* is the current buffer full ? */ 
   87         } prof_area[NB_PROF_BUFFER];
   88 
   89         int             prof_index;     /* index of the buffer structure
   90                                          *   currently in use */
   91 
   92 };
   93 typedef struct prof_data        *prof_data_t;
   94 #define NULLPBUF ((prof_data_t) 0)
   95 typedef struct buffer           *buffer_t;
   96 
   97 /* Macros */
   98 
   99 #define set_pbuf_nb(pbuf, nb) \
  100          (((nb) >= 0 && (nb) < NB_PROF_BUFFER) \
  101          ? (pbuf)->prof_index = (nb), 1 \
  102          : 0)
  103 
  104 
  105 #define get_pbuf_nb(pbuf) \
  106         (pbuf)->prof_index
  107 
  108 
  109 extern vm_map_t kernel_map; 
  110 
  111 #define dealloc_pbuf_area(pbuf) \
  112           { \
  113           register int i; \
  114                                    \
  115             for(i=0; i < NB_PROF_BUFFER ; i++)  \
  116               kmem_free(kernel_map, \
  117                         (vm_offset_t) (pbuf)->prof_area[i].p_zone, \
  118                         SIZE_PROF_BUFFER*sizeof(int)); \
  119             kmem_free(kernel_map, \
  120                           (vm_offset_t)(pbuf), \
  121                           sizeof(struct prof_data)); \
  122           }
  123         
  124 
  125 #define alloc_pbuf_area(pbuf, vmpbuf) \
  126       (vmpbuf) = (vm_offset_t) 0; \
  127       if (kmem_alloc(kernel_map, &(vmpbuf) , sizeof(struct prof_data)) == \
  128                                            KERN_SUCCESS) { \
  129            register int i; \
  130            register boolean_t end; \
  131                                    \
  132            (pbuf) = (prof_data_t) (vmpbuf); \
  133            for(i=0, end=FALSE; i < NB_PROF_BUFFER && end == FALSE; i++) { \
  134               (vmpbuf) = (vm_offset_t) 0; \
  135               if (kmem_alloc(kernel_map,&(vmpbuf),SIZE_PROF_BUFFER*sizeof(int)) == KERN_SUCCESS) { \
  136                  (pbuf)->prof_area[i].p_zone = (int *) (vmpbuf); \
  137                  (pbuf)->prof_area[i].p_full = FALSE; \
  138               } \
  139               else { \
  140                  (pbuf) = NULLPBUF; \
  141                  end = TRUE; \
  142               } \
  143             } \
  144         } \
  145         else \
  146           (pbuf) = NULLPBUF; 
  147         
  148 
  149 
  150 /* MACRO set_pbuf_value 
  151 ** 
  152 ** enters the value 'val' in the buffer 'pbuf' and returns the following
  153 ** indications:     0: means that a fatal error occured: the buffer was full
  154 **                       (it hasn't been sent yet)
  155 **                  1: means that a value has been inserted successfully
  156 **                  2: means that we'v just entered the last value causing 
  157 **                      the current buffer to be full.(must switch to 
  158 **                      another buffer and signal the sender to send it)
  159 */ 
  160           
  161 #define set_pbuf_value(pbuf, val) \
  162          { \
  163           register buffer_t a = &((pbuf)->prof_area[(pbuf)->prof_index]); \
  164           register int i = a->p_index++; \
  165           register boolean_t f = a->p_full; \
  166                           \
  167           if (f == TRUE ) \
  168              *(val) = 0; \
  169           else { \
  170             a->p_zone[i] = *(val); \
  171             if (i == SIZE_PROF_BUFFER-1) { \
  172                a->p_full = TRUE; \
  173                *(val) = 2; \
  174             } \
  175             else \
  176                 *(val) = 1; \
  177           } \
  178         }
  179 
  180          
  181 #define reset_pbuf_area(pbuf) \
  182         { \
  183          register int *i = &((pbuf)->prof_index); \
  184                                               \
  185          *i = (*i == NB_PROF_BUFFER-1) ? 0 : ++(*i); \
  186          (pbuf)->prof_area[*i].p_index = 0; \
  187         }
  188 
  189 
  190 /**************************************************************/
  191 /* Structure, elements used for queuing operations on buffers */
  192 /**************************************************************/
  193 
  194 #define thread_t int *
  195 /*
  196 ** This must be done in order to avoid a circular inclusion 
  197 ** with file kern/thread.h . 
  198 ** When using this data structure, one must cast the actual 
  199 ** type, this is (int *) or (thread_t)
  200 */
  201 
  202 struct buf_to_send {
  203         queue_chain_t list;
  204         thread_t thread;
  205         int number;         /* the number of the buffer to be sent */
  206         char wakeme;        /* do wakeup when buffer has been sent */
  207         }       ;
  208 
  209 #undef  thread_t
  210 
  211 
  212 
  213 typedef struct buf_to_send *buf_to_send_t;
  214 
  215 #define NULLBTS         ((buf_to_send_t) 0)
  216 
  217 /*
  218 ** Global variable: the head of the queue of buffers to send 
  219 ** It is a queue with locks (uses macros from queue.h) and it
  220 ** is shared by hardclock() and the sender_thread() 
  221 */
  222 
  223 mpqueue_head_t prof_queue; 
  224 
  225 #endif  /* _MACH_PROF_H_ */

Cache object: f90b52afa907f7a12da64efdb1ecc59d


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