summaryrefslogtreecommitdiff
path: root/vm/vm_object.h
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-07-25 02:26:36 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-08-15 12:43:26 +0200
commitff8600ee5a6fd0f1a80848abf8adcfd3ee13fb77 (patch)
tree2f2db46f32e2435a5326255f39df8c388d03c7da /vm/vm_object.h
parentfff012df46942c355a705b91a342923b7680002c (diff)
vm/object: use a general lock to protect vm objects
* vm/vm_object.h (struct vm_object): Use a general lock, adapt macros.
Diffstat (limited to 'vm/vm_object.h')
-rw-r--r--vm/vm_object.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/vm/vm_object.h b/vm/vm_object.h
index 3bfc67a..3c9055f 100644
--- a/vm/vm_object.h
+++ b/vm/vm_object.h
@@ -63,7 +63,7 @@ typedef struct ipc_port * pager_request_t;
struct vm_object {
queue_chain_t memq; /* Resident memory */
- decl_simple_lock_data(, Lock) /* Synchronization */
+ struct lock Lock; /* Synchronization */
#if VM_OBJECT_DEBUG
thread_t LockHolder; /* Thread holding Lock */
#endif /* VM_OBJECT_DEBUG */
@@ -336,14 +336,15 @@ vm_object_t vm_object_copy_delayed(
*/
#if VM_OBJECT_DEBUG
+
#define vm_object_lock_init(object) \
MACRO_BEGIN \
- simple_lock_init(&(object)->Lock); \
+ lock_init(&(object)->Lock, TRUE); \
(object)->LockHolder = 0; \
MACRO_END
#define vm_object_lock(object) \
MACRO_BEGIN \
- simple_lock(&(object)->Lock); \
+ lock_write(&(object)->Lock); \
(object)->LockHolder = current_thread(); \
MACRO_END
#define vm_object_unlock(object) \
@@ -351,10 +352,10 @@ MACRO_BEGIN \
if ((object)->LockHolder != current_thread()) \
panic("vm_object_unlock 0x%x", (object)); \
(object)->LockHolder = 0; \
- simple_unlock(&(object)->Lock); \
+ lock_done(&(object)->Lock); \
MACRO_END
#define vm_object_lock_try(object) \
- (simple_lock_try(&(object)->Lock) \
+ (lock_try_write(&(object)->Lock) \
? ( ((object)->LockHolder = current_thread()) , TRUE) \
: FALSE)
#define vm_object_sleep(event, object, interruptible) \
@@ -362,20 +363,20 @@ MACRO_BEGIN \
if ((object)->LockHolder != current_thread()) \
panic("vm_object_sleep %#x", (object)); \
(object)->LockHolder = 0; \
- thread_sleep((event_t)(event), simple_lock_addr((object)->Lock), \
+ thread_sleep_lock((event_t)(event), &(object)->Lock, \
(interruptible)); \
MACRO_END
#define vm_object_lock_taken(object) \
((object)->LockHolder == current_thread())
#else /* VM_OBJECT_DEBUG */
-#define vm_object_lock_init(object) simple_lock_init(&(object)->Lock)
-#define vm_object_lock(object) simple_lock(&(object)->Lock)
-#define vm_object_unlock(object) simple_unlock(&(object)->Lock)
-#define vm_object_lock_try(object) simple_lock_try(&(object)->Lock)
+#define vm_object_lock_init(object) lock_init(&(object)->Lock, TRUE)
+#define vm_object_lock(object) lock_write(&(object)->Lock)
+#define vm_object_unlock(object) lock_done(&(object)->Lock)
+#define vm_object_lock_try(object) lock_try_write(&(object)->Lock)
#define vm_object_sleep(event, object, interruptible) \
- thread_sleep((event_t)(event), simple_lock_addr((object)->Lock), \
+ thread_sleep_lock((event_t)(event), &(object)->Lock, \
(interruptible))
-#define vm_object_lock_taken(object) simple_lock_taken(&(object)->Lock)
+#define vm_object_lock_taken(object) lock_taken(&(object)->Lock)
#endif /* VM_OBJECT_DEBUG */
/*