Subversion Repositories Kolibri OS

Rev

Rev 2137 | Rev 2167 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2137 Rev 2146
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 2137 $
8
$Revision: 2146 $
9
 
9
 
10
 
10
 
Line 219... Line 219...
219
 
219
 
220
 
220
 
221
 
221
 
222
struc MUTEX_WAITER
-
 
223
{
222
struc MUTEX_WAITER
224
    .next   rd 1
223
{
225
    .prev   rd 1
224
    .list   LHEAD
Line 226... Line 225...
226
    .task   rd 1
225
    .task   rd 1
Line 233... Line 232...
233
 
232
 
Line 234... Line 233...
234
;void  __fastcall mutex_init(struct mutex *lock)
233
;void  __fastcall mutex_init(struct mutex *lock)
235
 
234
 
236
align 4
235
align 4
-
 
236
mutex_init:
237
mutex_init:
237
        mov [ecx+MUTEX.wait.next], ecx
238
        lea eax, [ecx+MUTEX.next]
-
 
239
        mov [ecx+MUTEX.count],1
-
 
240
        mov [ecx+MUTEX.next], eax
238
        mov [ecx+MUTEX.wait.prev], ecx
Line 241... Line 239...
241
        mov [ecx+MUTEX.prev], eax
239
        mov [ecx+MUTEX.count],1
Line 251... Line 249...
251
        jns .done
249
        jns .done
Line 252... Line 250...
252
 
250
 
253
        pushfd
251
        pushfd
Line 254... Line -...
254
        cli
-
 
255
 
252
        cli
Line 256... Line -...
256
        push esi
-
 
257
        sub esp, MUTEX_WAITER.sizeof
-
 
258
 
-
 
259
        mov eax, [ecx+MUTEX.prev]
-
 
260
        lea esi, [ecx+MUTEX.next]
-
 
261
 
253
 
262
        mov [ecx+MUTEX.prev], esp
-
 
Line 263... Line 254...
263
        mov [esp+MUTEX_WAITER.next],  esi
254
        sub esp, MUTEX_WAITER.sizeof
264
        mov [esp+MUTEX_WAITER.prev],  eax
255
 
Line 265... Line 256...
265
        mov [eax], esp
256
        list_add_tail esp, ecx      ;esp= new waiter, ecx= list head
Line 276... Line 267...
276
 
267
 
277
        mov [edx+TASKDATA.state], 1
268
        mov [edx+TASKDATA.state], 1
278
        call change_task
269
        call change_task
279
        jmp .forever
270
        jmp .forever
280
@@:
271
@@:
281
        mov edx, [esp+MUTEX_WAITER.next]
272
        mov edx, [esp+MUTEX_WAITER.list.next]
Line 282... Line 273...
282
        mov eax, [esp+MUTEX_WAITER.prev]
273
        mov eax, [esp+MUTEX_WAITER.list.prev]
283
 
274
 
284
        mov [eax+MUTEX_WAITER.next], edx
275
        mov [eax+MUTEX_WAITER.list.next], edx
285
        cmp [ecx+MUTEX.next], esi
276
        mov [edx+MUTEX_WAITER.list.prev], eax
Line 286... Line 277...
286
        mov [edx+MUTEX_WAITER.prev], eax
277
        cmp [ecx+MUTEX.wait.next], ecx
287
        jne @F
278
        jne @F
288
 
279
 
Line 289... Line -...
289
        mov [ecx+MUTEX.count], 0
-
 
290
@@:
280
        mov [ecx+MUTEX.count], 0
291
        add  esp, MUTEX_WAITER.sizeof
281
@@:
292
 
282
        add  esp, MUTEX_WAITER.sizeof
Line 293... Line 283...
293
        pop esi
283
 
Line 301... Line 291...
301
mutex_unlock:
291
mutex_unlock:
Line 302... Line 292...
302
 
292
 
303
        pushfd
293
        pushfd
Line 304... Line 294...
304
        cli
294
        cli
305
 
-
 
306
        lea edx, [ecx+MUTEX.next]
295
 
307
        mov eax, [edx]
296
        mov eax, [ecx+MUTEX.wait.next]
308
        cmp eax, edx
297
        cmp eax, ecx
Line 309... Line 298...
309
        mov [ecx+MUTEX.count], 1
298
        mov [ecx+MUTEX.count], 1
310
        je @F
299
        je @F