summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-07-25 02:13:17 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-08-15 12:43:26 +0200
commitc73b49b93e583d6fe9fdbfe18c540e0e3eaa6bd1 (patch)
tree2f90e8591ef573db9ad681350647c86f1a40fdb0 /vm
parenta532bf98740841143d881898c0047b1065d9e11c (diff)
vm: use a general lock to protect the default memory manager
* vm/memory_object.c: Use a general lock to protect the default memory manager.
Diffstat (limited to 'vm')
-rw-r--r--vm/memory_object.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/vm/memory_object.c b/vm/memory_object.c
index 097ed23..eeba168 100644
--- a/vm/memory_object.c
+++ b/vm/memory_object.c
@@ -73,8 +73,15 @@ typedef int memory_object_lock_result_t; /* moved from below */
ipc_port_t memory_manager_default = IP_NULL;
-decl_simple_lock_data(,memory_manager_default_lock)
+struct lock default_memory_manager_lock_data;
+
+#define default_memory_manager_lock_init() \
+ lock_init(&default_memory_manager_lock_data, FALSE)
+#define default_memory_manager_lock() \
+ lock_write(&default_memory_manager_lock_data)
+#define default_memory_manager_unlock() \
+ lock_write_done(&default_memory_manager_lock_data)
/*
* Important note:
* All of these routines gain a reference to the
@@ -1033,7 +1040,7 @@ kern_return_t vm_set_default_memory_manager(host, default_manager)
return(KERN_INVALID_HOST);
new_manager = *default_manager;
- simple_lock(&memory_manager_default_lock);
+ default_memory_manager_lock();
current_manager = memory_manager_default;
if (new_manager == IP_NULL) {
@@ -1060,7 +1067,7 @@ kern_return_t vm_set_default_memory_manager(host, default_manager)
thread_wakeup((event_t) &memory_manager_default);
}
- simple_unlock(&memory_manager_default_lock);
+ default_memory_manager_unlock();
*default_manager = returned_manager;
return(KERN_SUCCESS);
@@ -1078,17 +1085,17 @@ ipc_port_t memory_manager_default_reference(void)
{
ipc_port_t current_manager;
- simple_lock(&memory_manager_default_lock);
+ default_memory_manager_lock();
while (current_manager = ipc_port_copy_send(memory_manager_default),
!IP_VALID(current_manager)) {
- thread_sleep((event_t) &memory_manager_default,
- simple_lock_addr(memory_manager_default_lock),
+ thread_sleep_lock((event_t) &memory_manager_default,
+ &default_memory_manager_lock_data,
FALSE);
- simple_lock(&memory_manager_default_lock);
+ default_memory_manager_lock();
}
- simple_unlock(&memory_manager_default_lock);
+ default_memory_manager_unlock();
return current_manager;
}
@@ -1109,7 +1116,7 @@ boolean_t memory_manager_default_port(port)
ipc_port_t current;
boolean_t result;
- simple_lock(&memory_manager_default_lock);
+ default_memory_manager_lock();
current = memory_manager_default;
if (IP_VALID(current)) {
/*
@@ -1122,7 +1129,7 @@ boolean_t memory_manager_default_port(port)
result = port->ip_receiver == current->ip_receiver;
} else
result = FALSE;
- simple_unlock(&memory_manager_default_lock);
+ default_memory_manager_unlock();
return result;
}
@@ -1130,5 +1137,5 @@ boolean_t memory_manager_default_port(port)
void memory_manager_default_init(void)
{
memory_manager_default = IP_NULL;
- simple_lock_init(&memory_manager_default_lock);
+ default_memory_manager_lock_init();
}