1 /* $NetBSD: rf_mcpair.c,v 1.21 2006/11/16 01:33:23 christos Exp $ */
3 * Copyright (c) 1995 Carnegie-Mellon University.
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.
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.
18 * Carnegie Mellon requests users of this software to return to
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
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.
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.21 2006/11/16 01:33:23 christos Exp $");
37 #include <dev/raidframe/raidframevar.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"
50 #define RF_MAX_FREE_MCPAIR 128
51 #define RF_MIN_FREE_MCPAIR 24
53 static void rf_ShutdownMCPair(void *);
56 rf_ShutdownMCPair(void *ignored
)
58 pool_destroy(&rf_pools
.mcpair
);
62 rf_ConfigureMCPair(RF_ShutdownList_t
**listp
)
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
);
77 t
= pool_get(&rf_pools
.mcpair
, PR_WAITOK
);
78 simple_lock_init(&t
->mutex
);
86 rf_FreeMCPair(RF_MCPair_t
*t
)
88 pool_put(&rf_pools
.mcpair
, t
);
91 /* the callback function used to wake you up when you use an mcpair to
94 rf_MCPairWakeupFunc(RF_MCPair_t
*mcpair
)
96 RF_LOCK_MUTEX(mcpair
->mutex
);
98 wakeup(&(mcpair
->cond
));
99 RF_UNLOCK_MUTEX(mcpair
->mutex
);