Rev 787 | Rev 1104 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 787 | Rev 1100 | ||
---|---|---|---|
Line 49... | Line 49... | ||
49 | #ifdef CONFIG_DEBUG_SPINLOCK |
49 | #ifdef CONFIG_DEBUG_SPINLOCK |
50 | sl->name = name; |
50 | sl->name = name; |
51 | #endif |
51 | #endif |
52 | } |
52 | } |
53 | 53 | ||
54 | #ifdef CONFIG_DEBUG_SPINLOCK |
- | |
55 | /** Lock spinlock |
54 | /** Lock spinlock |
56 | * |
55 | * |
57 | * Lock spinlock. |
56 | * Lock spinlock. |
58 | * This version has limitted ability to report |
57 | * This version has limitted ability to report |
59 | * possible occurence of deadlock. |
58 | * possible occurence of deadlock. |
60 | * |
59 | * |
61 | * @param sl Pointer to spinlock_t structure. |
60 | * @param sl Pointer to spinlock_t structure. |
62 | */ |
61 | */ |
- | 62 | #ifdef CONFIG_DEBUG_SPINLOCK |
|
63 | void spinlock_lock(spinlock_t *sl) |
63 | void spinlock_lock_debug(spinlock_t *sl) |
64 | { |
64 | { |
65 | count_t i = 0; |
65 | count_t i = 0; |
66 | char *symbol; |
66 | char *symbol; |
67 | bool deadlock_reported = false; |
67 | bool deadlock_reported = false; |
68 | 68 | ||
Line 85... | Line 85... | ||
85 | 85 | ||
86 | /* |
86 | /* |
87 | * Prevent critical section code from bleeding out this way up. |
87 | * Prevent critical section code from bleeding out this way up. |
88 | */ |
88 | */ |
89 | CS_ENTER_BARRIER(); |
89 | CS_ENTER_BARRIER(); |
90 | - | ||
91 | } |
- | |
92 | - | ||
93 | #else |
- | |
94 | - | ||
95 | /** Lock spinlock |
- | |
96 | * |
- | |
97 | * Lock spinlock. |
- | |
98 | * |
- | |
99 | * @param sl Pointer to spinlock_t structure. |
- | |
100 | */ |
- | |
101 | void spinlock_lock(spinlock_t *sl) |
- | |
102 | { |
- | |
103 | preemption_disable(); |
- | |
104 | - | ||
105 | /* |
- | |
106 | * Each architecture has its own efficient/recommended |
- | |
107 | * implementation of spinlock. |
- | |
108 | */ |
- | |
109 | spinlock_arch(&sl->val); |
- | |
110 | - | ||
111 | /* |
- | |
112 | * Prevent critical section code from bleeding out this way up. |
- | |
113 | */ |
- | |
114 | CS_ENTER_BARRIER(); |
- | |
115 | } |
90 | } |
116 | #endif |
91 | #endif |
117 | 92 | ||
118 | /** Lock spinlock conditionally |
93 | /** Lock spinlock conditionally |
119 | * |
94 | * |
Line 141... | Line 116... | ||
141 | preemption_enable(); |
116 | preemption_enable(); |
142 | 117 | ||
143 | return rc; |
118 | return rc; |
144 | } |
119 | } |
145 | 120 | ||
146 | /** Unlock spinlock |
- | |
147 | * |
- | |
148 | * Unlock spinlock. |
- | |
149 | * |
- | |
150 | * @param sl Pointer to spinlock_t structure. |
- | |
151 | */ |
- | |
152 | void spinlock_unlock(spinlock_t *sl) |
- | |
153 | { |
- | |
154 | ASSERT(atomic_get(&sl->val) != 0); |
- | |
155 | - | ||
156 | /* |
- | |
157 | * Prevent critical section code from bleeding out this way down. |
- | |
158 | */ |
- | |
159 | CS_LEAVE_BARRIER(); |
- | |
160 | - | ||
161 | atomic_set(&sl->val,0); |
- | |
162 | preemption_enable(); |
- | |
163 | } |
- | |
164 | - | ||
165 | #endif |
121 | #endif |