Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c721d26 in mainline


Ignore:
Timestamp:
2015-06-16T14:18:22Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
2654afb
Parents:
f7aa7a40
Message:

The async_futex must also be held during FIBRIL_FROM_DEAD.
Add the missing futex_down() to fibril_main() and async_manager().
Add an assert to fibril_switch().

Location:
uspace/lib/c
Files:
2 edited

Legend:

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

    rf7aa7a40 rc721d26  
    9696        fibril->retval = fibril->func(fibril->arg);
    9797       
     98        futex_down(&async_futex);
    9899        fibril_switch(FIBRIL_FROM_DEAD);
    99100        /* Not reached */
     
    147148/** Switch from the current fibril.
    148149 *
    149  * If calling with FIBRIL_TO_MANAGER parameter, the async_futex should be
    150  * held.
     150 * If stype is FIBRIL_TO_MANAGER or FIBRIL_FROM_DEAD, the async_futex must
     151 * be held.
    151152 *
    152153 * @param stype Switch type. One of FIBRIL_PREEMPT, FIBRIL_TO_MANAGER,
     
    163164       
    164165        futex_lock(&fibril_futex);
    165        
     166
    166167        if (stype == FIBRIL_PREEMPT && list_empty(&ready_list))
    167168                goto ret_0;
     
    183184        /* If we are going to manager and none exists, create it */
    184185        if ((stype == FIBRIL_TO_MANAGER) || (stype == FIBRIL_FROM_DEAD)) {
     186                /* Make sure the async_futex is held. */
     187                assert((atomic_signed_t) async_futex.val.count <= 0);
     188
    185189                while (list_empty(&manager_list)) {
    186190                        futex_unlock(&fibril_futex);
  • uspace/lib/c/include/async.h

    rf7aa7a40 rc721d26  
    108108
    109109#define async_manager() \
    110         fibril_switch(FIBRIL_TO_MANAGER)
     110        do { \
     111                futex_down(&async_futex); \
     112                fibril_switch(FIBRIL_FROM_DEAD); \
     113        } while (0)
    111114
    112115#define async_get_call(data) \
Note: See TracChangeset for help on using the changeset viewer.