Changeset 95838f1 in mainline for uspace/lib/c/generic/fibril_synch.c


Ignore:
Timestamp:
2018-06-25T21:45:15Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
38e3427
Parents:
3679f51a
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 20:58:01)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 21:45:15)
Message:

Switch async_futex to using futex_lock/unlock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/fibril_synch.c

    r3679f51a r95838f1  
    106106        fibril_t *f = (fibril_t *) fibril_get_id();
    107107
    108         futex_down(&async_futex);
     108        futex_lock(&async_futex);
    109109        if (fm->counter-- <= 0) {
    110110                awaiter_t wdata;
     
    119119        } else {
    120120                fm->oi.owned_by = f;
    121                 futex_up(&async_futex);
     121                futex_unlock(&async_futex);
    122122        }
    123123}
     
    127127        bool locked = false;
    128128
    129         futex_down(&async_futex);
     129        futex_lock(&async_futex);
    130130        if (fm->counter > 0) {
    131131                fm->counter--;
     
    133133                locked = true;
    134134        }
    135         futex_up(&async_futex);
     135        futex_unlock(&async_futex);
    136136
    137137        return locked;
     
    166166{
    167167        assert(fibril_mutex_is_locked(fm));
    168         futex_down(&async_futex);
     168        futex_lock(&async_futex);
    169169        _fibril_mutex_unlock_unsafe(fm);
    170         futex_up(&async_futex);
     170        futex_unlock(&async_futex);
    171171}
    172172
     
    175175        bool locked = false;
    176176
    177         futex_down(&async_futex);
     177        futex_lock(&async_futex);
    178178        if (fm->counter <= 0)
    179179                locked = true;
    180         futex_up(&async_futex);
     180        futex_unlock(&async_futex);
    181181
    182182        return locked;
     
    195195        fibril_t *f = (fibril_t *) fibril_get_id();
    196196
    197         futex_down(&async_futex);
     197        futex_lock(&async_futex);
    198198        if (frw->writers) {
    199199                awaiter_t wdata;
     
    211211                if (frw->readers++ == 0)
    212212                        frw->oi.owned_by = f;
    213                 futex_up(&async_futex);
     213                futex_unlock(&async_futex);
    214214        }
    215215}
     
    219219        fibril_t *f = (fibril_t *) fibril_get_id();
    220220
    221         futex_down(&async_futex);
     221        futex_lock(&async_futex);
    222222        if (frw->writers || frw->readers) {
    223223                awaiter_t wdata;
     
    234234                frw->oi.owned_by = f;
    235235                frw->writers++;
    236                 futex_up(&async_futex);
     236                futex_unlock(&async_futex);
    237237        }
    238238}
     
    240240static void _fibril_rwlock_common_unlock(fibril_rwlock_t *frw)
    241241{
    242         futex_down(&async_futex);
     242        futex_lock(&async_futex);
    243243        if (frw->readers) {
    244244                if (--frw->readers) {
     
    301301        }
    302302out:
    303         futex_up(&async_futex);
     303        futex_unlock(&async_futex);
    304304}
    305305
     
    320320        bool locked = false;
    321321
    322         futex_down(&async_futex);
     322        futex_lock(&async_futex);
    323323        if (frw->readers)
    324324                locked = true;
    325         futex_up(&async_futex);
     325        futex_unlock(&async_futex);
    326326
    327327        return locked;
     
    332332        bool locked = false;
    333333
    334         futex_down(&async_futex);
     334        futex_lock(&async_futex);
    335335        if (frw->writers) {
    336336                assert(frw->writers == 1);
    337337                locked = true;
    338338        }
    339         futex_up(&async_futex);
     339        futex_unlock(&async_futex);
    340340
    341341        return locked;
     
    369369        wdata.wu_event.inlist = true;
    370370
    371         futex_down(&async_futex);
     371        futex_lock(&async_futex);
    372372        if (timeout) {
    373373                getuptime(&wdata.to_event.expires);
     
    381381
    382382        /* async_futex not held after fibril_switch() */
    383         futex_down(&async_futex);
     383        futex_lock(&async_futex);
    384384        if (wdata.to_event.inlist)
    385385                list_remove(&wdata.to_event.link);
    386386        if (wdata.wu_event.inlist)
    387387                list_remove(&wdata.wu_event.link);
    388         futex_up(&async_futex);
     388        futex_unlock(&async_futex);
    389389
    390390        return wdata.to_event.occurred ? ETIMEOUT : EOK;
     
    404404        awaiter_t *wdp;
    405405
    406         futex_down(&async_futex);
     406        futex_lock(&async_futex);
    407407        while (!list_empty(&fcv->waiters)) {
    408408                tmp = list_first(&fcv->waiters);
     
    418418                }
    419419        }
    420         futex_up(&async_futex);
     420        futex_unlock(&async_futex);
    421421}
    422422
     
    657657void fibril_semaphore_up(fibril_semaphore_t *sem)
    658658{
    659         futex_down(&async_futex);
     659        futex_lock(&async_futex);
    660660        sem->count++;
    661661
    662662        if (sem->count > 0) {
    663                 futex_up(&async_futex);
     663                futex_unlock(&async_futex);
    664664                return;
    665665        }
     
    669669        list_remove(tmp);
    670670
    671         futex_up(&async_futex);
     671        futex_unlock(&async_futex);
    672672
    673673        awaiter_t *wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
     
    685685void fibril_semaphore_down(fibril_semaphore_t *sem)
    686686{
    687         futex_down(&async_futex);
     687        futex_lock(&async_futex);
    688688        sem->count--;
    689689
    690690        if (sem->count >= 0) {
    691                 futex_up(&async_futex);
     691                futex_unlock(&async_futex);
    692692                return;
    693693        }
Note: See TracChangeset for help on using the changeset viewer.