Changeset ab6edb6 in mainline for uspace/lib/c/generic/fibril_synch.c


Ignore:
Timestamp:
2018-06-26T17:34:48Z (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:
e768aea
Parents:
b59318e
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 19:28:19)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-26 17:34:48)
Message:

Simplify the interaction between async_futex and fibril_switch().

File:
1 edited

Legend:

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

    rb59318e rab6edb6  
    116116                check_for_deadlock(&fm->oi);
    117117                f->waits_for = &fm->oi;
    118                 fibril_switch(FIBRIL_TO_MANAGER);
     118                fibril_switch(FIBRIL_FROM_BLOCKED);
    119119        } else {
    120120                fm->oi.owned_by = f;
    121                 futex_unlock(&async_futex);
    122         }
     121        }
     122        futex_unlock(&async_futex);
    123123}
    124124
     
    206206                check_for_deadlock(&frw->oi);
    207207                f->waits_for = &frw->oi;
    208                 fibril_switch(FIBRIL_TO_MANAGER);
     208                fibril_switch(FIBRIL_FROM_BLOCKED);
    209209        } else {
    210210                /* Consider the first reader the owner. */
    211211                if (frw->readers++ == 0)
    212212                        frw->oi.owned_by = f;
    213                 futex_unlock(&async_futex);
    214         }
     213        }
     214        futex_unlock(&async_futex);
    215215}
    216216
     
    230230                check_for_deadlock(&frw->oi);
    231231                f->waits_for = &frw->oi;
    232                 fibril_switch(FIBRIL_TO_MANAGER);
     232                fibril_switch(FIBRIL_FROM_BLOCKED);
    233233        } else {
    234234                frw->oi.owned_by = f;
    235235                frw->writers++;
    236                 futex_unlock(&async_futex);
    237         }
     236        }
     237        futex_unlock(&async_futex);
    238238}
    239239
     
    377377        list_append(&wdata.wu_event.link, &fcv->waiters);
    378378        _fibril_mutex_unlock_unsafe(fm);
    379         fibril_switch(FIBRIL_TO_MANAGER);
     379        fibril_switch(FIBRIL_FROM_BLOCKED);
     380        futex_unlock(&async_futex);
     381
     382        // XXX: This could be replaced with an unlocked version to get rid
     383        // of the unlock-lock pair. I deliberately don't do that because
     384        // further changes would most likely need to revert that optimization.
    380385        fibril_mutex_lock(fm);
    381386
    382         /* async_futex not held after fibril_switch() */
    383387        futex_lock(&async_futex);
    384388        if (wdata.to_event.inlist)
     
    698702        wdata.fid = fibril_get_id();
    699703        list_append(&wdata.wu_event.link, &sem->waiters);
    700         fibril_switch(FIBRIL_TO_MANAGER);
    701 
    702         /* async_futex not held after fibril_switch() */
     704
     705        fibril_switch(FIBRIL_FROM_BLOCKED);
     706        futex_unlock(&async_futex);
    703707}
    704708
Note: See TracChangeset for help on using the changeset viewer.