summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-04-02 22:19:16 +0000
committerjhb <jhb@FreeBSD.org>2002-04-02 22:19:16 +0000
commit9d3d63fcbcfccaf091b15608a262de78b5912c8a (patch)
treea511bf3088c2455af875faa67fac4fc49ade8493 /sys/kern/kern_mutex.c
parent26f5df0f6761c5fad4b517e8c0c4b46da408361b (diff)
downloadFreeBSD-src-9d3d63fcbcfccaf091b15608a262de78b5912c8a.zip
FreeBSD-src-9d3d63fcbcfccaf091b15608a262de78b5912c8a.tar.gz
- Move the MI mutexes sched_lock and Giant from being declared in the
various machdep.c's to being declared in kern_mutex.c. - Add a new function mutex_init() used to perform early initialization needed for mutexes such as setting up thread0's contested lock list and initializing MI mutexes. Change the various MD startup routines to call this function instead of duplicating all the code themselves. Tested on: alpha, i386
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