Subversion Repositories Kolibri OS

Rev

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

Rev 5585 Rev 5590
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 5585 $
8
$Revision: 5590 $
9
 
9
 
Line 1479... Line 1479...
1479
@@:
1479
@@:
1480
        mov     [esp+32], eax
1480
        mov     [esp+32], eax
1481
        ret
1481
        ret
Line 1482... Line 1482...
1482
 
1482
 
-
 
1483
align 4
-
 
1484
;ecx futex handle
1483
align 4
1485
;edx new value
1484
.futex_wait:
1486
.futex_wait:
1485
        cmp     ecx, 3
1487
        cmp     ecx, 3
1486
        jb      .epicfail
1488
        jb      .epicfail
1487
        cmp     ecx, (PROC.pdt_0 - PROC.htab)/4
1489
        cmp     ecx, (PROC.pdt_0 - PROC.htab)/4
Line 1494... Line 1496...
1494
        jne     .epicfail
1496
        jne     .epicfail
1495
        cmp     [edi+FUTEX.handle], ecx
1497
        cmp     [edi+FUTEX.handle], ecx
1496
        jne     .epicfail
1498
        jne     .epicfail
Line 1497... Line 1499...
1497
 
1499
 
1498
        mov     ecx, [edi+FUTEX.pointer]
-
 
-
 
1500
        mov     ecx, [edi+FUTEX.pointer]
1499
        mov     edx, 1
1501
 
1500
        mov     eax, [ecx]
1502
        mov     eax, edx
1501
        test    eax, eax
1503
        lock cmpxchg [ecx], edx         ;wait until old_value == new_value
-
 
1504
        jz .wait_slow
1502
        jnz     .wait_slow
1505
 
1503
        lock cmpxchg [ecx], edx
1506
        mov     [esp+SYSCALL_STACK._eax], 0
Line 1504... Line 1507...
1504
        jz      .ok
1507
        ret
1505
 
1508
 
1506
.wait_slow:
1509
.wait_slow:
Line 1516... Line 1519...
1516
        list_add_tail esp, esi      ;esp= new waiter, esi= list head
1519
        list_add_tail esp, esi      ;esp= new waiter, esi= list head
Line 1517... Line 1520...
1517
 
1520
 
1518
.again:
1521
.again:
Line 1519... Line -...
1519
        call    change_task
-
 
1520
 
-
 
1521
        mov     eax, [ecx]
-
 
1522
        test    eax, eax
1522
        call    change_task
1523
        jnz     .again
1523
 
Line 1524... Line 1524...
1524
        lock cmpxchg [ecx], edx
1524
        lock cmpxchg [ecx], edx
1525
        jnz     .again
1525
        jz .again
Line 1526... Line 1526...
1526
 
1526
 
1527
        list_del esp
-
 
1528
        add     esp, sizeof.MUTEX_WAITER
1527
        list_del esp
1529
 
1528
        add     esp, sizeof.MUTEX_WAITER
Line 1530... Line 1529...
1530
        popfd
1529
 
1531
.ok:
1530
        popfd
1532
        mov     [esp+32], eax
1531
        mov     [esp+SYSCALL_STACK._eax], 0
Line 1533... Line 1532...
1533
        ret
1532
        ret
1534
 
1533
 
-
 
1534
.epicfail:
-
 
1535
        mov     [esp+SYSCALL_STACK._eax], -1
-
 
1536
        ret
-
 
1537
 
-
 
1538
align 4
-
 
1539
.futex_wake:
-
 
1540
        cmp     ecx, 3
-
 
1541
        jb      .epicfail
-
 
1542
        cmp     ecx, (PROC.pdt_0 - PROC.htab)/4
-
 
1543
        jae     .epicfail
-
 
1544
 
-
 
1545
        mov     esi, [current_process]
-
 
1546
        mov     edi, [esi+PROC.htab+ecx*4]
-
 
1547
 
-
 
1548
        cmp     [edi+FUTEX.magic], 'FUTX'
-
 
1549
        jne     .epicfail
-
 
1550
        cmp     [edi+FUTEX.handle], ecx
-
 
1551
        jne     .epicfail
-
 
1552
 
-
 
1553
        xor     ecx, ecx
-
 
1554
 
-
 
1555
        pushfd
-
 
1556
        cli
-
 
1557
 
-
 
1558
        lea     ebx, [edi+FUTEX.wait_list]
-
 
1559
        mov     esi, [edi+FUTEX.wait_list.next]
-
 
1560
@@:
-
 
1561
        cmp     esi, ebx
-
 
1562
        je      @F
-
 
1563
 
-
 
1564
        mov     eax, [esi+MUTEX_WAITER.task]
-
 
1565
        mov     [eax+TASKDATA.state], 0
-
 
1566
 
-
 
1567
        mov     esi, [esi+MUTEX_WAITER.list.next]
1535
.epicfail:
1568
        inc     ecx
Line -... Line 1569...
-
 
1569
        cmp     ecx, edx