1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
From bcef2e3112634dd780b9d694fcc3b266d45a203f Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sat, 25 Jul 2015 02:26:36 +0200
Subject: [PATCH gnumach 09/10] vm/object: use a general lock to protect vm
objects
* vm/vm_object.h (struct vm_object): Use a general lock, adapt macros.
---
vm/vm_object.h | 25 +++++++++++++------------
1 file 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 */
/*
--
2.1.4
|