Rev 6082 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6082 | Rev 9833 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | #include |
23 | #include |
24 | #include |
24 | #include |
25 | #include |
25 | #include |
26 | #include |
26 | #include |
Line 27... | Line -... | ||
27 | - | ||
28 | struct kos_taskdata |
- | |
29 | { |
- | |
30 | u32 event_mask; |
- | |
31 | u32 pid; |
- | |
32 | u16 r0; |
- | |
33 | u8 state; |
- | |
34 | u8 r1; |
- | |
35 | u16 r2; |
- | |
36 | u8 wnd_number; |
- | |
37 | u8 r3; |
- | |
38 | u32 mem_start; |
- | |
39 | u32 counter_sum; |
- | |
40 | u32 counter_add; |
- | |
41 | u32 cpu_usage; |
- | |
42 | }__attribute__((packed)); |
- | |
43 | 27 | ||
44 | static inline void mutex_set_owner(struct mutex *lock) |
28 | static inline void mutex_set_owner(struct mutex *lock) |
45 | { |
29 | { |
Line 46... | Line 30... | ||
46 | } |
30 | } |
Line 142... | Line 126... | ||
142 | * Uh oh, we raced in fastpath, wake up everyone in this case, |
126 | * Uh oh, we raced in fastpath, wake up everyone in this case, |
143 | * so they can see the new lock->ctx. |
127 | * so they can see the new lock->ctx. |
144 | */ |
128 | */ |
145 | flags = safe_cli(); |
129 | flags = safe_cli(); |
146 | list_for_each_entry(cur, &lock->base.wait_list, list) { |
130 | list_for_each_entry(cur, &lock->base.wait_list, list) { |
147 | ((struct kos_taskdata*)cur->task)->state = 0; |
131 | ((struct kos_appdata*)cur->task)->state = KOS_SLOT_STATE_RUNNING; |
148 | } |
132 | } |
149 | safe_sti(flags); |
133 | safe_sti(flags); |
150 | } |
134 | } |
Line -... | Line 135... | ||
- | 135 | ||
151 | 136 | static __always_inline void |
|
152 | ww_mutex_set_context_slowpath(struct ww_mutex *lock, |
137 | ww_mutex_set_context_slowpath(struct ww_mutex *lock, |
153 | struct ww_acquire_ctx *ctx) |
138 | struct ww_acquire_ctx *ctx) |
154 | { |
139 | { |
Line 160... | Line 145... | ||
160 | /* |
145 | /* |
161 | * Give any possible sleeping processes the chance to wake up, |
146 | * Give any possible sleeping processes the chance to wake up, |
162 | * so they can recheck if they have to back off. |
147 | * so they can recheck if they have to back off. |
163 | */ |
148 | */ |
164 | list_for_each_entry(cur, &lock->base.wait_list, list) { |
149 | list_for_each_entry(cur, &lock->base.wait_list, list) { |
165 | ((struct kos_taskdata*)cur->task)->state = 0; |
150 | ((struct kos_appdata*)cur->task)->state = KOS_SLOT_STATE_RUNNING; |
166 | } |
151 | } |
167 | } |
152 | } |
Line 168... | Line 153... | ||
168 | 153 | ||
169 | int __ww_mutex_lock_slowpath(struct ww_mutex *ww, struct ww_acquire_ctx *ctx) |
154 | int __ww_mutex_lock_slowpath(struct ww_mutex *ww, struct ww_acquire_ctx *ctx) |
170 | { |
155 | { |
171 | struct mutex *lock; |
156 | struct mutex *lock; |
172 | struct mutex_waiter waiter; |
157 | struct mutex_waiter waiter; |
173 | struct kos_taskdata* taskdata; |
158 | struct kos_appdata *appdata; |
174 | u32 eflags; |
159 | u32 eflags; |
Line 175... | Line 160... | ||
175 | int ret = 0; |
160 | int ret = 0; |
176 | 161 | ||
177 | lock = &ww->base; |
162 | lock = &ww->base; |
Line 178... | Line 163... | ||
178 | taskdata = (struct kos_taskdata*)(0x80003010); |
163 | appdata = GetCurrSlot(); |
Line 179... | Line 164... | ||
179 | waiter.task = (u32*)taskdata; |
164 | waiter.task = appdata; |
Line 190... | Line 175... | ||
190 | if (ctx->acquired > 0) { |
175 | if (ctx->acquired > 0) { |
191 | ret = __ww_mutex_lock_check_stamp(lock, ctx); |
176 | ret = __ww_mutex_lock_check_stamp(lock, ctx); |
192 | if (ret) |
177 | if (ret) |
193 | goto err; |
178 | goto err; |
194 | }; |
179 | }; |
195 | taskdata->state = 1; |
180 | appdata->state = KOS_SLOT_STATE_SUSPENDED; |
196 | change_task(); |
181 | change_task(); |
197 | }; |
182 | }; |
Line 198... | Line 183... | ||
198 | 183 | ||
199 | if (likely(list_empty(&lock->wait_list))) |
184 | if (likely(list_empty(&lock->wait_list))) |