diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-07-25 02:13:17 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-14 14:45:05 +0200 |
commit | b4083eca87a1406edbd5b048e1dc2d894ddf425c (patch) | |
tree | 67d21b81a6d804d1246331a62a495a5c2594f6a8 /vm/memory_object.c | |
parent | 57c0b5bfc39c8effaa21bd4b70f83b42859467e0 (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/memory_object.c')
-rw-r--r-- | vm/memory_object.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/vm/memory_object.c b/vm/memory_object.c index 0a07429..44f21c5 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 @@ -1038,7 +1045,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) { @@ -1065,7 +1072,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); @@ -1083,17 +1090,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; } @@ -1114,7 +1121,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)) { /* @@ -1127,7 +1134,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; } @@ -1135,5 +1142,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(); } |