Changeset 32efd86 in mainline


Ignore:
Timestamp:
2010-11-06T10:07:30Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
409f5fc
Parents:
0578271 (diff), 9414abc (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:

Merge from lp:~jakub/helenos/deadlock-detection.

File:
1 edited

Legend:

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

    r0578271 r32efd86  
    180180void fibril_rwlock_read_lock(fibril_rwlock_t *frw)
    181181{
     182        fibril_t *f = (fibril_t *) fibril_get_id();
     183       
    182184        futex_down(&async_futex);
    183185        if (frw->writers) {
    184                 fibril_t *f = (fibril_t *) fibril_get_id();
    185186                awaiter_t wdata;
    186187
     
    195196                fibril_switch(FIBRIL_TO_MANAGER);
    196197        } else {
    197                 frw->readers++;
     198                /* Consider the first reader the owner. */
     199                if (frw->readers++ == 0)
     200                        frw->oi.owned_by = f;
    198201                futex_up(&async_futex);
    199202        }
     
    229232        assert(frw->readers || (frw->writers == 1));
    230233        if (frw->readers) {
    231                 if (--frw->readers)
     234                if (--frw->readers) {
     235                        if (frw->oi.owned_by == (fibril_t *) fibril_get_id()) {
     236                                /*
     237                                 * If this reader firbril was considered the
     238                                 * owner of this rwlock, clear the ownership
     239                                 * information even if there are still more
     240                                 * readers.
     241                                 *
     242                                 * This is the limitation of the detection
     243                                 * mechanism rooted in the fact that tracking
     244                                 * all readers would require dynamically
     245                                 * allocated memory for keeping linkage info.
     246                                 */
     247                                frw->oi.owned_by = NULL;
     248                        }
    232249                        goto out;
     250                }
    233251        } else {
    234252                frw->writers--;
     
    265283                        list_remove(&wdp->wu_event.link);
    266284                        fibril_add_ready(wdp->fid);
    267                         frw->readers++;
     285                        if (frw->readers++ == 0) {
     286                                /* Consider the first reader the owner. */
     287                                frw->oi.owned_by = f;
     288                        }
    268289                        optimize_execution_power();
    269290                }
Note: See TracChangeset for help on using the changeset viewer.