Rev 6079 | Rev 7136 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6079 | Rev 6089 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | ;; ;; |
5 | ;; ;; |
6 | ;; Synhronization for MenuetOS. ;; |
6 | ;; Synhronization for MenuetOS. ;; |
7 | ;; Author: Halyavin Andrey, halyavin@land.ru ;; |
7 | ;; Author: Halyavin Andrey, halyavin@land.ru ;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 9... | Line 9... | ||
9 | 9 | ||
Line 10... | Line 10... | ||
10 | $Revision: 6079 $ |
10 | $Revision: 6089 $ |
11 | 11 | ||
12 | align 4 |
12 | align 4 |
13 | ;struct futex* __fastcall create_futex(int *ptr) |
13 | ;struct futex* __fastcall create_futex(int *ptr) |
Line 130... | Line 130... | ||
130 | .futex_wait: |
130 | .futex_wait: |
131 | test esi, esi |
131 | test esi, esi |
132 | jnz .futex_wait_timeout |
132 | jnz .futex_wait_timeout |
133 | mov ecx, [ebp+FUTEX.pointer] |
133 | mov ecx, [ebp+FUTEX.pointer] |
134 | mov eax, edx |
134 | mov eax, edx |
135 | lock cmpxchg [ecx], edx ;wait until old_value == new_value |
135 | lock cmpxchg [ecx], edx |
136 | jz .wait_slow |
136 | je .wait_slow |
Line 137... | Line 137... | ||
137 | 137 | ||
138 | mov [esp+SYSCALL_STACK._eax], 0 |
138 | mov [esp+SYSCALL_STACK._eax], -2 |
Line 139... | Line 139... | ||
139 | ret |
139 | ret |
140 | 140 | ||
141 | .wait_slow: |
141 | .wait_slow: |
Line 146... | Line 146... | ||
146 | mov ebx, [TASK_BASE] |
146 | mov ebx, [TASK_BASE] |
147 | mov [esp+MUTEX_WAITER.task], ebx |
147 | mov [esp+MUTEX_WAITER.task], ebx |
148 | lea esi, [ebp+FUTEX.wait_list] |
148 | lea esi, [ebp+FUTEX.wait_list] |
Line 149... | Line 149... | ||
149 | 149 | ||
150 | list_add_tail esp, esi ;esp= new waiter, esi= list head |
- | |
- | 150 | list_add_tail esp, esi ;esp= new waiter, esi= list head |
|
151 | 151 | mov eax, edx |
|
152 | .again: |
152 | .again: |
153 | mov [ebx+TASKDATA.state], 1 |
153 | mov [ebx+TASKDATA.state], 1 |
Line 154... | Line 154... | ||
154 | call change_task |
154 | call change_task |
155 | 155 | ||
Line 156... | Line 156... | ||
156 | lock cmpxchg [ecx], edx |
156 | lock cmpxchg [ecx], edx |
157 | jz .again |
157 | je .again |
Line 158... | Line 158... | ||
158 | 158 | ||
Line 172... | Line 172... | ||
172 | 172 | ||
173 | .futex_wait_timeout: |
173 | .futex_wait_timeout: |
174 | mov ecx, [ebp+FUTEX.pointer] |
174 | mov ecx, [ebp+FUTEX.pointer] |
175 | mov eax, edx |
175 | mov eax, edx |
176 | lock cmpxchg [ecx], edx ;wait until old_value == new_value |
176 | lock cmpxchg [ecx], edx ;wait until old_value == new_value |
Line 177... | Line 177... | ||
177 | jz .wait_slow_timeout |
177 | je .wait_slow_timeout |
178 | 178 | ||
Line 179... | Line 179... | ||
179 | mov [esp+SYSCALL_STACK._eax], 0 |
179 | mov [esp+SYSCALL_STACK._eax], -2 |
180 | ret |
180 | ret |
181 | 181 | ||
Line 208... | Line 208... | ||
208 | call change_task |
208 | call change_task |
209 | mov eax, [ebx+APPDATA.wait_param] |
209 | mov eax, [ebx+APPDATA.wait_param] |
210 | test eax, eax |
210 | test eax, eax |
211 | jz .timeout |
211 | jz .timeout |
Line -... | Line 212... | ||
- | 212 | ||
212 | 213 | mov eax, edx |
|
213 | lock cmpxchg [ecx], edx |
214 | lock cmpxchg [ecx], edx |
214 | jz .again_timeout |
215 | jz .again_timeout |
215 | @@: |
216 | @@: |
216 | list_del esp |
217 | list_del esp |