Changeset 649efcd in mainline


Ignore:
Timestamp:
2010-11-05T15:56:29Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
55bd76c
Parents:
84b7384
Message:

Add support for detecting deadlocks involving fibril rwlocks.

Readers are only tracked when waiting for a rwlock, but it is unfortunatelly not
possible to track their ownership of a rwlock. Because of this, some deadlock
scenarios can go unnoticed by the detection system.

File:
1 edited

Legend:

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

    r84b7384 r649efcd  
    194194                f->flags &= ~FIBRIL_WRITER;
    195195                list_append(&wdata.wu_event.link, &frw->waiters);
     196               
     197                if (check_for_deadlock(&frw->oi))
     198                        print_deadlock(&frw->oi);
     199                f->waits_for = &frw->oi;
     200               
    196201                fibril_switch(FIBRIL_TO_MANAGER);
    197202        } else {
     
    203208void fibril_rwlock_write_lock(fibril_rwlock_t *frw)
    204209{
     210        fibril_t *f = (fibril_t *) fibril_get_id();
     211       
    205212        futex_down(&async_futex);
    206213        if (frw->writers || frw->readers) {
    207                 fibril_t *f = (fibril_t *) fibril_get_id();
    208214                awaiter_t wdata;
    209215
     
    214220                f->flags |= FIBRIL_WRITER;
    215221                list_append(&wdata.wu_event.link, &frw->waiters);
     222               
     223                if (check_for_deadlock(&frw->oi))
     224                        print_deadlock(&frw->oi);
     225                f->waits_for = &frw->oi;
     226               
    216227                fibril_switch(FIBRIL_TO_MANAGER);
    217228        } else {
     229                frw->oi.owned_by = f;
    218230                frw->writers++;
    219231                futex_up(&async_futex);
     
    234246        assert(!frw->readers && !frw->writers);
    235247       
     248        frw->oi.owned_by = NULL;
     249       
    236250        while (!list_empty(&frw->waiters)) {
    237251                link_t *tmp = frw->waiters.next;
     
    241255                wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
    242256                f = (fibril_t *) wdp->fid;
     257               
     258                f->waits_for = NULL;
    243259               
    244260                if (f->flags & FIBRIL_WRITER) {
     
    250266                        fibril_add_ready(wdp->fid);
    251267                        frw->writers++;
     268                        frw->oi.owned_by = f;
    252269                        optimize_execution_power();
    253270                        break;
Note: See TracChangeset for help on using the changeset viewer.