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/savar.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 /*      $NetBSD: savar.h,v 1.15 2004/03/14 01:08:47 cl Exp $    */
    2 
    3 /*-
    4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Nathan J. Williams.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 /*
   40  * Internal data usd by the scheduler activation implementation
   41  */
   42 
   43 #ifndef _SYS_SAVAR_H
   44 #define _SYS_SAVAR_H
   45 
   46 #include <sys/lock.h>
   47 #include <sys/tree.h>
   48 #include <sys/queue.h>
   49 
   50 union sau_state {
   51         struct {
   52                 ucontext_t      ss_ctx;
   53                 struct sa_t     ss_sa;
   54         } ss_captured;
   55         struct {
   56                 struct lwp      *ss_lwp;
   57         } ss_deferred;
   58 };
   59 
   60 struct sadata_upcall {
   61         SIMPLEQ_ENTRY(sadata_upcall)    sau_next;
   62         int     sau_flags;
   63         int     sau_type;
   64         size_t  sau_argsize;
   65         void    *sau_arg;
   66         stack_t sau_stack;
   67         union sau_state sau_event;
   68         union sau_state sau_interrupted;
   69 };
   70 
   71 #define SAU_FLAG_DEFERRED_EVENT         0x1
   72 #define SAU_FLAG_DEFERRED_INTERRUPTED   0x2
   73 
   74 #define SA_UPCALL_TYPE_MASK             0x00FF
   75 
   76 #define SA_UPCALL_DEFER_EVENT           0x1000
   77 #define SA_UPCALL_DEFER_INTERRUPTED     0x2000
   78 #define SA_UPCALL_DEFER                 (SA_UPCALL_DEFER_EVENT | \
   79                                          SA_UPCALL_DEFER_INTERRUPTED)
   80 
   81 struct sastack {
   82         stack_t                 sast_stack;
   83         SPLAY_ENTRY(sastack)    sast_node;
   84         unsigned int            sast_gen;
   85 };
   86 
   87 struct sadata_vp {
   88         int     savp_id;                /* "virtual processor" identifier */
   89         SLIST_ENTRY(sadata_vp)  savp_next; /* link to next sadata_vp */
   90         struct simplelock       savp_lock; /* lock on these fields */
   91         struct lwp      *savp_lwp;      /* lwp on "virtual processor" */
   92         struct lwp      *savp_blocker;  /* recently blocked lwp */
   93         struct lwp      *savp_wokenq_head; /* list of woken lwps */
   94         struct lwp      **savp_wokenq_tailp; /* list of woken lwps */
   95         vaddr_t savp_faultaddr;         /* page fault address */
   96         vaddr_t savp_ofaultaddr;        /* old page fault address */
   97         LIST_HEAD(, lwp)        savp_lwpcache; /* list of available lwps */
   98         int     savp_ncached;           /* list length */
   99         SIMPLEQ_HEAD(, sadata_upcall)   savp_upcalls; /* pending upcalls */
  100 };
  101 
  102 struct sadata {
  103         struct simplelock sa_lock;      /* lock on these fields */
  104         int     sa_flag;                /* SA_* flags */
  105         sa_upcall_t     sa_upcall;      /* upcall entry point */
  106         int     sa_concurrency;         /* current concurrency */
  107         int     sa_maxconcurrency;      /* requested concurrency */
  108         SPLAY_HEAD(sasttree, sastack) sa_stackstree; /* tree of upcall stacks */
  109         struct sastack  *sa_stacknext;  /* next free stack */
  110         ssize_t sa_stackinfo_offset;    /* offset from ss_sp to stackinfo data */
  111         int     sa_nstacks;             /* number of upcall stacks */
  112         SLIST_HEAD(, sadata_vp) sa_vps; /* list of "virtual processors" */
  113 };
  114 
  115 #define SA_FLAG_ALL     SA_FLAG_PREEMPT
  116 
  117 extern struct pool sadata_pool;         /* memory pool for sadata structures */
  118 extern struct pool saupcall_pool;       /* memory pool for pending upcalls */
  119 extern struct pool sastack_pool;        /* memory pool for sastack structs */
  120 extern struct pool savp_pool;           /* memory pool for sadata_vp structures */
  121 
  122 #ifdef _KERNEL
  123 #include <sys/mallocvar.h>
  124 
  125 MALLOC_DECLARE(M_SA);
  126 #endif
  127 
  128 #define SA_MAXNUMSTACKS 16              /* Maximum number of upcall stacks per VP. */
  129 
  130 struct sadata_upcall *sadata_upcall_alloc(int);
  131 void    sadata_upcall_free(struct sadata_upcall *);
  132 
  133 void    sa_release(struct proc *);
  134 void    sa_switch(struct lwp *, int);
  135 void    sa_preempt(struct lwp *);
  136 void    sa_yield(struct lwp *);
  137 int     sa_upcall(struct lwp *, int, struct lwp *, struct lwp *, size_t, void *);
  138 
  139 void    sa_putcachelwp(struct proc *, struct lwp *);
  140 struct lwp *sa_getcachelwp(struct sadata_vp *);
  141 
  142 
  143 void    sa_unblock_userret(struct lwp *);
  144 void    sa_upcall_userret(struct lwp *);
  145 void    cpu_upcall(struct lwp *, int, int, int, void *, void *, void *, sa_upcall_t);
  146 
  147 #endif /* !_SYS_SAVAR_H */

Cache object: 83b2a8314b7290c6e7f89ec62d112705


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