Subversion Repositories Kolibri OS

Rev

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

Rev 5565 Rev 5585
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: 5565 $
8
$Revision: 5585 $
9
 
9
 
Line 1169... Line 1169...
1169
        ret
1169
        ret
1170
endp
1170
endp
Line 1171... Line 1171...
1171
 
1171
 
1172
align 4
1172
align 4
1173
sysfn_meminfo:
-
 
1174
 
-
 
1175
        ;   add ecx, new_app_base
1173
sysfn_meminfo:
1176
        cmp     ecx, OS_BASE
1174
        cmp     ecx, OS_BASE
Line 1177... Line 1175...
1177
        jae     .fail
1175
        jae     .fail
1178
 
1176
 
Line 1446... Line 1444...
1446
        dec     ecx
1444
        dec     ecx
1447
        jnz     @b
1445
        jnz     @b
1448
.done:
1446
.done:
1449
        ret
1447
        ret
1450
endp
1448
endp
-
 
1449
 
-
 
1450
FUTEX_INIT      equ 0
-
 
1451
FUTEX_WAIT      equ 1
-
 
1452
FUTEX_WAKE      equ 2
-
 
1453
 
-
 
1454
align 4
-
 
1455
f77call:
-
 
1456
        dd f77.futex_init     ;0
-
 
1457
        dd f77.futex_wait     ;1
-
 
1458
        dd f77.futex_wake     ;2
-
 
1459
 
-
 
1460
align 4
-
 
1461
sys_synchronization:
-
 
1462
f77:
-
 
1463
        cmp     ebx, FUTEX_WAKE
-
 
1464
        ja .fail
-
 
1465
 
-
 
1466
        jmp     dword [f77call+ebx*4]
-
 
1467
 
-
 
1468
.fail:
-
 
1469
        mov     [esp+32], dword 0
-
 
1470
        ret
-
 
1471
 
-
 
1472
 
-
 
1473
align 4
-
 
1474
.futex_init:
-
 
1475
        call    create_futex
-
 
1476
        test    eax, eax
-
 
1477
        jz      @F
-
 
1478
        mov     eax, [eax+FUTEX.handle]
-
 
1479
@@:
-
 
1480
        mov     [esp+32], eax
-
 
1481
        ret
-
 
1482
 
-
 
1483
align 4
-
 
1484
.futex_wait:
-
 
1485
        cmp     ecx, 3
-
 
1486
        jb      .epicfail
-
 
1487
        cmp     ecx, (PROC.pdt_0 - PROC.htab)/4
-
 
1488
        jae     .epicfail
-
 
1489
 
-
 
1490
        mov     esi, [current_process]
-
 
1491
        mov     edi, [esi+PROC.htab+ecx*4]
-
 
1492
 
-
 
1493
        cmp     [edi+FUTEX.magic], 'FUTX'
-
 
1494
        jne     .epicfail
-
 
1495
        cmp     [edi+FUTEX.handle], ecx
-
 
1496
        jne     .epicfail
-
 
1497
 
-
 
1498
        mov     ecx, [edi+FUTEX.pointer]
-
 
1499
        mov     edx, 1
-
 
1500
        mov     eax, [ecx]
-
 
1501
        test    eax, eax
-
 
1502
        jnz     .wait_slow
-
 
1503
        lock cmpxchg [ecx], edx
-
 
1504
        jz      .ok
-
 
1505
 
-
 
1506
.wait_slow:
-
 
1507
        pushfd
-
 
1508
        cli
-
 
1509
 
-
 
1510
        sub     esp, sizeof.MUTEX_WAITER
-
 
1511
        mov     ebx, [TASK_BASE]
-
 
1512
        mov     [ebx+TASKDATA.state], 1
-
 
1513
        mov     [esp+MUTEX_WAITER.task], ebx
-
 
1514
        lea     esi, [edi+FUTEX.wait_list]
-
 
1515
 
-
 
1516
        list_add_tail esp, esi      ;esp= new waiter, esi= list head
-
 
1517
 
-
 
1518
.again:
-
 
1519
        call    change_task
-
 
1520
 
-
 
1521
        mov     eax, [ecx]
-
 
1522
        test    eax, eax
-
 
1523
        jnz     .again
-
 
1524
        lock cmpxchg [ecx], edx
-
 
1525
        jnz     .again
-
 
1526
 
-
 
1527
        list_del esp
-
 
1528
        add     esp, sizeof.MUTEX_WAITER
-
 
1529
 
-
 
1530
        popfd
-
 
1531
.ok:
-
 
1532
        mov     [esp+32], eax
-
 
1533
        ret
-
 
1534
 
-
 
1535
.epicfail:
-
 
1536
        mov     [esp+32], dword -1
-
 
1537
        ret
-
 
1538
 
-
 
1539
align 4
-
 
1540
.futex_wake:
-
 
1541
        ret
-
 
1542