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/norma/ipc_kserver.c

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 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  * HISTORY
   28  * $Log:        ipc_kserver.c,v $
   29  * Revision 2.12  93/05/15  19:33:23  mrt
   30  *      machparam.h -> machspl.h
   31  * 
   32  * Revision 2.11  93/01/14  17:53:50  danner
   33  *      64bit cleanup. Proper spl typing.
   34  *      [92/12/01            af]
   35  * 
   36  * Revision 2.10  92/03/10  16:27:35  jsb
   37  *      Merged in norma branch changes as of NORMA_MK7.
   38  *      [92/03/09  12:49:17  jsb]
   39  * 
   40  * Revision 2.9.2.4  92/02/21  11:24:20  jsb
   41  *      In norma_kserver_deliver, don't convert reply to network format.
   42  *      [92/02/21  09:04:29  jsb]
   43  * 
   44  * Revision 2.9.2.3  92/01/21  21:51:15  jsb
   45  *      De-linted.
   46  *      [92/01/17  12:20:44  jsb]
   47  * 
   48  * Revision 2.9.2.2  92/01/09  18:45:24  jsb
   49  *      Added kernel_kmsg_lock. Use splhigh/splx instead of sploff/splon.
   50  *      [92/01/08  10:03:53  jsb]
   51  * 
   52  * Revision 2.9.2.1  92/01/03  16:37:23  jsb
   53  *      Corrected log.
   54  *      [91/12/24  14:34:11  jsb]
   55  * 
   56  * Revision 2.9  91/12/15  10:42:15  jsb
   57  *      Added norma_ipc_finish_receiving call to support large in-line msgs.
   58  * 
   59  * Revision 2.8  91/12/14  14:34:23  jsb
   60  *      Removed ipc_fields.h hack.
   61  * 
   62  * Revision 2.7  91/12/10  13:26:03  jsb
   63  *      Use ipc_kmsg_copyout_to_network instead of ipc_kmsg_copyin_from_kernel.
   64  *      [91/12/10  11:27:15  jsb]
   65  * 
   66  * Revision 2.6  91/11/14  16:52:24  rpd
   67  *      Added ipc_fields.h hack.
   68  *      Use IP_NORMA_IS_PROXY macro instead of ipc_space_remote.
   69  *      Added missing argument to kernel_thread().
   70  *      [91/11/00            jsb]
   71  * 
   72  * Revision 2.5  91/08/28  11:16:03  jsb
   73  *      As a hack to avoid printfs from i860ipsc/spl.c,
   74  *      defined sploff/splon as splsched/splx.
   75  *      [91/08/27  21:59:34  jsb]
   76  * 
   77  *      Renamed clport things to norma things.
   78  *      [91/08/15  09:11:36  jsb]
   79  * 
   80  * Revision 2.4  91/08/03  18:19:22  jsb
   81  *      Replaced spldcm/splx with sploff/splon.
   82  *      [91/07/28  20:52:22  jsb]
   83  * 
   84  *      Removed obsolete includes and vm and kmsg munging operations.
   85  *      [91/07/17  14:14:11  jsb]
   86  * 
   87  *      Moved MACH_MSGH_BITS_COMPLEX_{PORTS,DATA} to mach/message.h.
   88  *      [91/07/04  13:12:09  jsb]
   89  * 
   90  *      Use vm_map_copy_t page_lists instead of old style page_lists.
   91  *      [91/07/04  10:20:35  jsb]
   92  * 
   93  * Revision 2.3  91/07/01  08:25:30  jsb
   94  *      Changes for new vm_map_copy_t definition.
   95  *      [91/06/29  16:38:27  jsb]
   96  * 
   97  * Revision 2.2  91/06/17  15:47:44  jsb
   98  *      Moved here from ipc/ipc_clkobject.c.
   99  *      [91/06/17  11:05:35  jsb]
  100  * 
  101  * Revision 2.2  91/06/06  17:05:23  jsb
  102  *      First checkin.
  103  *      [91/05/24  13:10:00  jsb]
  104  * 
  105  */
  106 /*
  107  *      File:   norma/ipc_kserver.c
  108  *      Author: Joseph S. Barrera III
  109  *      Date:   1991
  110  *
  111  *      Functions to support ipc between nodes in a single Mach cluster.
  112  */
  113 
  114 #include <machine/machspl.h>
  115 #include <vm/vm_kern.h>
  116 #include <vm/vm_page.h>
  117 #include <mach/vm_param.h>
  118 #include <mach/port.h>
  119 #include <mach/message.h>
  120 #include <kern/assert.h>
  121 #include <kern/host.h>
  122 #include <kern/sched_prim.h>
  123 #include <kern/ipc_sched.h>
  124 #include <kern/ipc_kobject.h>
  125 #include <kern/zalloc.h>
  126 #include <ipc/ipc_mqueue.h>
  127 #include <ipc/ipc_thread.h>
  128 #include <ipc/ipc_kmsg.h>
  129 #include <ipc/ipc_port.h>
  130 #include <ipc/ipc_pset.h>
  131 #include <ipc/ipc_space.h>
  132 #include <ipc/ipc_marequest.h>
  133 
  134 #define NUM_KSERVER_THREADS     4
  135 
  136 /*
  137  * Problems:
  138  *      Kserver_awake should be used but isn't.
  139  *      We used to replenish here; should we still?
  140  *      Kernel_kmsg list is ugly; we should use a queue.
  141  */
  142 
  143 decl_simple_lock_data(,kernel_kmsg_lock)
  144 ipc_kmsg_t kernel_kmsg = (ipc_kmsg_t) 0;
  145 boolean_t kserver_awake = FALSE;
  146 int kserver_awaken = 0;
  147 
  148 /*
  149  * Service request, perhaps blocking; send reply, if any.
  150  */
  151 norma_kserver_deliver(kmsg)
  152         ipc_kmsg_t kmsg;
  153 {
  154         ipc_port_t port;
  155 
  156         norma_ipc_finish_receiving(&kmsg);
  157         kmsg = ipc_kobject_server(kmsg);
  158         if (kmsg != IKM_NULL) {
  159                 port = (ipc_port_t) kmsg->ikm_header.msgh_remote_port;
  160                 if (IP_NORMA_IS_PROXY(port)) {
  161                         (void) norma_ipc_send(kmsg);
  162                 } else {
  163                         ipc_mqueue_send_always(kmsg);
  164                 }
  165         }
  166 }
  167 
  168 void
  169 kserver_continue()
  170 {
  171         spl_t s;
  172         ipc_kmsg_t kmsg;
  173 
  174         for (;;) {
  175                 kserver_awaken++;
  176 
  177                 simple_lock(&kernel_kmsg_lock);
  178                 s = splhigh();
  179                 while (kernel_kmsg) {
  180                         kmsg = kernel_kmsg;
  181                         kernel_kmsg = kmsg->ikm_next;
  182                         splx(s);
  183                         simple_unlock(&kernel_kmsg_lock);
  184                         norma_kserver_deliver(kmsg);
  185                         s = splhigh();
  186                         simple_lock(&kernel_kmsg_lock);
  187                 }
  188 
  189                 kserver_awake = FALSE;
  190                 assert_wait((vm_offset_t) &kserver_awake, FALSE);
  191                 (void) splx(s);
  192                 simple_unlock(&kernel_kmsg_lock);
  193                 thread_block(kserver_continue);
  194         }
  195 }
  196 
  197 void
  198 kserver_thread()
  199 {
  200         spl_t   s;
  201         
  202         thread_set_own_priority(0);     /* high priority */
  203 
  204         s = splhigh();
  205         kserver_awake = FALSE;
  206         assert_wait((vm_offset_t) &kserver_awake, FALSE);
  207         (void) splx(s);
  208 
  209         thread_block(kserver_continue);
  210         kserver_continue();
  211         /*NOTREACHED*/
  212 }
  213 
  214 void
  215 norma_ipc_kobject_send(kmsg)
  216         ipc_kmsg_t kmsg;
  217 {
  218         if (kernel_kmsg) {
  219                 ipc_kmsg_t km;
  220                 for (km = kernel_kmsg; km->ikm_next; ) {
  221                         km = km->ikm_next;
  222                 }
  223                 km->ikm_next = kmsg;
  224         } else {
  225                 kernel_kmsg = kmsg;
  226         }
  227         kmsg->ikm_next = 0;
  228 #if 0
  229         if (! kserver_awake) {
  230                 thread_wakeup_one((vm_offset_t) &kserver_awake);
  231         }
  232 #else
  233         thread_wakeup_one((vm_offset_t) &kserver_awake);
  234 #endif
  235 }
  236 
  237 norma_kserver_startup()
  238 {
  239         int i;
  240 
  241         for (i = 0; i < NUM_KSERVER_THREADS; i++) {
  242                 (void) kernel_thread(kernel_task, kserver_thread, (char *) 0);
  243         }
  244 }

Cache object: ea8327bf13873036b3b2a3190daf119f


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