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


Ignore:
Timestamp:
2015-06-17T23:45:24Z (9 years ago)
Author:
Michal Koutný <xm.koutny+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
523b17a
Parents:
fc7bf19 (diff), 2654afb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Sync with mainline

File:
1 edited

Legend:

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

    rfc7bf19 rcf3aee19  
    105105        fibril_t *f = (fibril_t *) fibril_get_id();
    106106
    107         if (fibril_get_sercount() != 0)
    108                 abort();
    109 
    110107        futex_down(&async_futex);
    111108        if (fm->counter-- <= 0) {
     
    197194        fibril_t *f = (fibril_t *) fibril_get_id();
    198195       
    199         if (fibril_get_sercount() != 0)
    200                 abort();
    201 
    202196        futex_down(&async_futex);
    203197        if (frw->writers) {
     
    224218        fibril_t *f = (fibril_t *) fibril_get_id();
    225219       
    226         if (fibril_get_sercount() != 0)
    227                 abort();
    228 
    229220        futex_down(&async_futex);
    230221        if (frw->writers || frw->readers) {
     
    461452                        if (rc == ETIMEOUT && timer->state == fts_active) {
    462453                                timer->state = fts_fired;
    463                                 timer->handler_running = true;
     454                                timer->handler_fid = fibril_get_id();
    464455                                fibril_mutex_unlock(timer->lockp);
    465456                                timer->fun(timer->arg);
    466457                                fibril_mutex_lock(timer->lockp);
    467                                 timer->handler_running = false;
     458                                timer->handler_fid = 0;
    468459                        }
    469460                        break;
     
    477468        /* Acknowledge timer fibril has finished cleanup. */
    478469        timer->state = fts_clean;
     470        fibril_condvar_broadcast(&timer->cv);
    479471        fibril_mutex_unlock(timer->lockp);
    480         free(timer);
    481472
    482473        return 0;
     
    525516        timer->state = fts_cleanup;
    526517        fibril_condvar_broadcast(&timer->cv);
     518
     519        /* Wait for timer fibril to terminate */
     520        while (timer->state != fts_clean)
     521                fibril_condvar_wait(&timer->cv, timer->lockp);
    527522        fibril_mutex_unlock(timer->lockp);
     523
     524        free(timer);
    528525}
    529526
     
    608605        assert(fibril_mutex_is_locked(timer->lockp));
    609606
    610         while (timer->handler_running)
     607        while (timer->handler_fid != 0) {
     608                if (timer->handler_fid == fibril_get_id()) {
     609                        printf("Deadlock detected.\n");
     610                        stacktrace_print();
     611                        printf("Fibril %zx is trying to clear timer %p from "
     612                            "inside its handler %p.\n",
     613                            fibril_get_id(), timer, timer->fun);
     614                        abort();
     615                }
     616
    611617                fibril_condvar_wait(&timer->cv, timer->lockp);
     618        }
    612619
    613620        old_state = timer->state;
Note: See TracChangeset for help on using the changeset viewer.