summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kern/host.c6
-rw-r--r--kern/mach_factor.c4
-rw-r--r--kern/processor.c14
-rw-r--r--kern/processor.h5
-rw-r--r--kern/sched_prim.c4
-rw-r--r--kern/task.c8
-rw-r--r--kern/thread.c8
7 files changed, 26 insertions, 23 deletions
diff --git a/kern/host.c b/kern/host.c
index 2855cd2..86955a6 100644
--- a/kern/host.c
+++ b/kern/host.c
@@ -244,7 +244,7 @@ host_processor_sets(
size = 0; addr = 0;
for (;;) {
- simple_lock(&all_psets_lock);
+ lock_all_psets();
actual = all_psets_count;
/* do we have the memory we need? */
@@ -254,7 +254,7 @@ host_processor_sets(
break;
/* unlock and allocate more memory */
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
if (size != 0)
kfree(addr, size);
@@ -281,7 +281,7 @@ host_processor_sets(
assert(queue_end(&all_psets, (queue_entry_t) pset));
/* can unlock now that we've got the pset refs */
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
/*
* Always have default port.
diff --git a/kern/mach_factor.c b/kern/mach_factor.c
index debce0b..6598707 100644
--- a/kern/mach_factor.c
+++ b/kern/mach_factor.c
@@ -63,7 +63,7 @@ void compute_mach_factor(void)
long average_now;
long load_now;
- simple_lock(&all_psets_lock);
+ lock_all_psets();
pset = (processor_set_t) queue_first(&all_psets);
while (!queue_end(&all_psets, (queue_entry_t)pset)) {
@@ -146,5 +146,5 @@ void compute_mach_factor(void)
pset = (processor_set_t) queue_next(&pset->all_psets);
}
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
}
diff --git a/kern/processor.c b/kern/processor.c
index a7c3fbf..bc70dde 100644
--- a/kern/processor.c
+++ b/kern/processor.c
@@ -60,7 +60,7 @@ struct processor processor_array[NCPUS];
queue_head_t all_psets;
int all_psets_count;
-decl_simple_lock_data(, all_psets_lock);
+struct lock all_psets_lock_data;
processor_t master_processor;
processor_t processor_ptr[NCPUS];
@@ -84,7 +84,7 @@ void pset_sys_bootstrap(void)
}
master_processor = cpu_to_processor(master_cpu);
queue_init(&all_psets);
- simple_lock_init(&all_psets_lock);
+ all_psets_lock_init();
queue_enter(&all_psets, &default_pset, processor_set_t, all_psets);
all_psets_count = 1;
default_pset.active = TRUE;
@@ -357,14 +357,14 @@ void pset_deallocate(
pset->ref_count = 1;
pset_ref_unlock(pset);
- simple_lock(&all_psets_lock);
+ lock_all_psets();
pset_ref_lock(pset);
if (--pset->ref_count > 0) {
/*
* Made an extra reference.
*/
pset_ref_unlock(pset);
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
return;
}
@@ -383,7 +383,7 @@ void pset_deallocate(
all_psets_count--;
pset_ref_unlock(pset);
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
/*
* That's it, free data structure.
@@ -539,10 +539,10 @@ processor_set_create(
ipc_pset_init(pset);
pset->active = TRUE;
- simple_lock(&all_psets_lock);
+ lock_all_psets();
queue_enter(&all_psets, pset, processor_set_t, all_psets);
all_psets_count++;
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
ipc_pset_enable(pset);
diff --git a/kern/processor.h b/kern/processor.h
index 69ddf87..b52ecda 100644
--- a/kern/processor.h
+++ b/kern/processor.h
@@ -117,7 +117,10 @@ extern struct processor processor_array[NCPUS];
*/
extern queue_head_t all_psets;
extern int all_psets_count;
-decl_simple_lock_data(extern, all_psets_lock);
+extern struct lock all_psets_lock_data;
+#define all_psets_lock_init() lock_init(&all_psets_lock_data, FALSE)
+#define lock_all_psets() lock_write(&all_psets_lock_data)
+#define unlock_all_psets() lock_write_done(&all_psets_lock_data)
/*
* The lock ordering is:
diff --git a/kern/sched_prim.c b/kern/sched_prim.c
index e354a21..aa6bb92 100644
--- a/kern/sched_prim.c
+++ b/kern/sched_prim.c
@@ -1969,12 +1969,12 @@ void do_thread_scan(void)
do {
#if MACH_HOST
- simple_lock(&all_psets_lock);
+ lock_all_psets();
queue_iterate(&all_psets, pset, processor_set_t, all_psets) {
if (restart_needed = do_runq_scan(&pset->runq))
break;
}
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
#else /* MACH_HOST */
restart_needed = do_runq_scan(&default_pset.runq);
#endif /* MACH_HOST */
diff --git a/kern/task.c b/kern/task.c
index 9a3d848..3b91de2 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -1141,14 +1141,14 @@ void task_collect_scan(void)
prev_task = TASK_NULL;
prev_pset = PROCESSOR_SET_NULL;
- simple_lock(&all_psets_lock);
+ lock_all_psets();
queue_iterate(&all_psets, pset, processor_set_t, all_psets) {
pset_lock(pset);
queue_iterate(&pset->tasks, task, task_t, pset_tasks) {
task_reference(task);
pset_reference(pset);
pset_unlock(pset);
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
machine_task_collect (task);
pmap_collect(task->map->pmap);
@@ -1161,12 +1161,12 @@ void task_collect_scan(void)
pset_deallocate(prev_pset);
prev_pset = pset;
- simple_lock(&all_psets_lock);
+ lock_all_psets();
pset_lock(pset);
}
pset_unlock(pset);
}
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
if (prev_task != TASK_NULL)
task_deallocate(prev_task);
diff --git a/kern/thread.c b/kern/thread.c
index 865a1cc..ebc0bdd 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -2250,7 +2250,7 @@ void thread_collect_scan(void)
prev_thread = THREAD_NULL;
prev_pset = PROCESSOR_SET_NULL;
- simple_lock(&all_psets_lock);
+ lock_all_psets();
queue_iterate(&all_psets, pset, processor_set_t, all_psets) {
pset_lock(pset);
queue_iterate(&pset->threads, thread, thread_t, pset_threads) {
@@ -2269,7 +2269,7 @@ void thread_collect_scan(void)
(void) splx(s);
pset->ref_count++;
pset_unlock(pset);
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
pcb_collect(thread);
@@ -2281,7 +2281,7 @@ void thread_collect_scan(void)
pset_deallocate(prev_pset);
prev_pset = pset;
- simple_lock(&all_psets_lock);
+ lock_all_psets();
pset_lock(pset);
} else {
thread_unlock(thread);
@@ -2290,7 +2290,7 @@ void thread_collect_scan(void)
}
pset_unlock(pset);
}
- simple_unlock(&all_psets_lock);
+ unlock_all_psets();
if (prev_thread != THREAD_NULL)
thread_deallocate(prev_thread);