Subversion Repositories Kolibri OS

Rev

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

Rev 6068 Rev 6099
Line 54... Line 54...
54
        return;
54
        return;
Line 55... Line 55...
55
 
55
 
56
    while (exchange_acquire (&mutex->lock, 2) != 0)
56
    while (exchange_acquire (&mutex->lock, 2) != 0)
57
    {
57
    {
58
        asm volatile(
58
        asm volatile(
59
        "int $0x40\t"
59
        "int $0x40\t\n"
60
        :"=a"(tmp)
60
        :"=a"(tmp)
61
        :"a"(77),"b"(FUTEX_WAIT),
61
        :"a"(77),"b"(FUTEX_WAIT),
62
        "c"(mutex->handle),"d"(2),"S"(0));
62
        "c"(mutex->handle),"d"(2),"S"(0));
63
   }
63
   }
Line 64... Line 64...
64
};
64
};
65
 
65
 
66
static inline void mutex_lock_timeout(mutex_t *mutex, int timeout)
66
static inline int mutex_lock_timeout(mutex_t *mutex, int timeout)
Line 67... Line 67...
67
{
67
{
68
    int tmp;
68
    int tmp = 0;
Line 69... Line 69...
69
 
69
 
70
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
70
    if( __sync_fetch_and_add(&mutex->lock, 1) == 0)
71
        return;
71
        return 1;
72
 
72
 
73
    while (exchange_acquire (&mutex->lock, 2) != 0)
73
    while (exchange_acquire (&mutex->lock, 2) != 0)
74
    {
74
    {
75
        asm volatile(
75
        asm volatile(
-
 
76
        "int $0x40\t"
-
 
77
        :"=a"(tmp)
-
 
78
        :"a"(77),"b"(FUTEX_WAIT),
76
        "int $0x40\t"
79
        "c"(mutex->handle),"d"(2),"S"(timeout));
-
 
80
 
77
        :"=a"(tmp)
81
        if(++tmp == 0)
Line 78... Line 82...
78
        :"a"(77),"b"(FUTEX_WAIT),
82
            break;
79
        "c"(mutex->handle),"d"(2),"S"(timeout));
83
    }
80
   }
84
    return tmp ;