summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
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 d547519..3207ee1 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
OpenPOWER on IntegriCloud