summaryrefslogtreecommitdiff
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2002-04-02 22:19:16 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2002-04-02 22:19:16 +0000
commitc53c013bae4d2813cfdf899b712f649ccd686012 (patch)
treea511bf3088c2455af875faa67fac4fc49ade8493 /sys/kern/kern_mutex.c
parent43e73ba0c27be6b3a25c57ec74315afe24b2aa38 (diff)
Notes
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index d54751908a46..3207ee1d3d99 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -81,6 +81,12 @@ struct lock_class lock_class_mtx_spin = {
};
/*
+ * System-wide mutexes
+ */
+struct mtx sched_lock;
+struct mtx Giant;
+
+/*
* Prototypes for non-exported routines.
*/
static void propagate_priority(struct thread *);
@@ -863,6 +869,27 @@ mtx_destroy(struct mtx *m)
}
/*
+ * Intialize the mutex code and system mutexes. This is called from the MD
+ * startup code prior to mi_startup(). The per-CPU data space needs to be
+ * setup before this is called.
+ */
+void
+mutex_init(void)
+{
+
+ /* Setup thread0 so that mutexes work. */
+ LIST_INIT(&thread0.td_contested);
+
+ /*
+ * Initialize mutexes.
+ */
+ mtx_init(&Giant, "Giant", MTX_DEF | MTX_RECURSE);
+ mtx_init(&sched_lock, "sched lock", MTX_SPIN | MTX_RECURSE);
+ mtx_init(&proc0.p_mtx, "process lock", MTX_DEF | MTX_DUPOK);
+ mtx_lock(&Giant);
+}
+
+/*
* Encapsulated Giant mutex routines. These routines provide encapsulation
* control for the Giant mutex, allowing sysctls to be used to turn on and
* off Giant around certain subsystems. The default value for the sysctls