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/dev/raidframe/rf_mcpair.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 /*      $NetBSD: rf_mcpair.c,v 1.17 2004/03/07 22:15:19 oster Exp $     */
    2 /*
    3  * Copyright (c) 1995 Carnegie-Mellon University.
    4  * All rights reserved.
    5  *
    6  * Author: Jim Zelenka
    7  *
    8  * Permission to use, copy, modify and distribute this software and
    9  * its documentation is hereby granted, provided that both the copyright
   10  * notice and this permission notice appear in all copies of the
   11  * software, derivative works or modified versions, and any portions
   12  * thereof, and that both notices appear in supporting documentation.
   13  *
   14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
   16  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   17  *
   18  * Carnegie Mellon requests users of this software to return to
   19  *
   20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   21  *  School of Computer Science
   22  *  Carnegie Mellon University
   23  *  Pittsburgh PA 15213-3890
   24  *
   25  * any improvements or extensions that they make and grant Carnegie the
   26  * rights to redistribute these changes.
   27  */
   28 
   29 /* rf_mcpair.c
   30  * an mcpair is a structure containing a mutex and a condition variable.
   31  * it's used to block the current thread until some event occurs.
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.17 2004/03/07 22:15:19 oster Exp $");
   36 
   37 #include <dev/raidframe/raidframevar.h>
   38 
   39 #include "rf_archs.h"
   40 #include "rf_threadstuff.h"
   41 #include "rf_mcpair.h"
   42 #include "rf_debugMem.h"
   43 #include "rf_general.h"
   44 #include "rf_shutdown.h"
   45 #include "rf_netbsd.h"
   46 
   47 #include <sys/pool.h>
   48 #include <sys/proc.h>
   49 
   50 #define RF_MAX_FREE_MCPAIR 128
   51 #define RF_MIN_FREE_MCPAIR  24
   52 
   53 static void rf_ShutdownMCPair(void *);
   54 
   55 static void 
   56 rf_ShutdownMCPair(void *ignored)
   57 {
   58         pool_destroy(&rf_pools.mcpair);
   59 }
   60 
   61 int 
   62 rf_ConfigureMCPair(RF_ShutdownList_t **listp)
   63 {
   64 
   65         rf_pool_init(&rf_pools.mcpair, sizeof(RF_MCPair_t),
   66                      "rf_mcpair_pl", RF_MIN_FREE_MCPAIR, RF_MAX_FREE_MCPAIR);
   67         rf_ShutdownCreate(listp, rf_ShutdownMCPair, NULL);
   68 
   69         return (0);
   70 }
   71 
   72 RF_MCPair_t *
   73 rf_AllocMCPair()
   74 {
   75         RF_MCPair_t *t;
   76 
   77         t = pool_get(&rf_pools.mcpair, PR_WAITOK);
   78         simple_lock_init(&t->mutex);
   79         t->cond = 0;
   80         t->flag = 0;
   81 
   82         return (t);
   83 }
   84 
   85 void 
   86 rf_FreeMCPair(RF_MCPair_t *t)
   87 {
   88         pool_put(&rf_pools.mcpair, t);
   89 }
   90 
   91 /* the callback function used to wake you up when you use an mcpair to
   92    wait for something */
   93 void 
   94 rf_MCPairWakeupFunc(RF_MCPair_t *mcpair)
   95 {
   96         RF_LOCK_MUTEX(mcpair->mutex);
   97         mcpair->flag = 1;
   98         wakeup(&(mcpair->cond));
   99         RF_UNLOCK_MUTEX(mcpair->mutex);
  100 }

Cache object: cc2e3cab2fc940702d7a3c757ac45172


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