Changeset 78a1b7b in mainline for uspace/srv/fs/fat/fat_idx.c


Ignore:
Timestamp:
2008-05-16T21:31:31Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
add5835
Parents:
4452366
Message:

Introduce a futex protecting the up_hash and ui_hash.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_idx.c

    r4452366 r78a1b7b  
    7474/** List of unused structures. */
    7575static LIST_INITIALIZE(unused_head);
     76
     77/** Futex protecting the up_hash and ui_hash.
     78 *
     79 * The locking strategy assumes that there will be at most one fibril for each
     80 * dev_handle.  Therefore it will be sufficient to hold the futex for shorter
     81 * times (i.e. only during hash table operations as opposed to holding it the
     82 * whole time between an unsuccessful find and the following insert). Should the
     83 * assumption break, the locking strategy for this futex will have to be
     84 * reconsidered.
     85 */
     86static futex_t used_futex = FUTEX_INITIALIZER;
    7687
    7788/**
     
    340351        };
    341352
     353        futex_down(&used_futex);
    342354        l = hash_table_find(&up_hash, pkey);
     355        futex_up(&used_futex);
    343356        if (l) {
    344357                fidx = hash_table_get_instance(l, fat_idx_t, uph_link);
     
    365378                fidx->nodep = NULL;
    366379
     380                futex_down(&used_futex);
    367381                hash_table_insert(&up_hash, pkey, &fidx->uph_link);
    368382                hash_table_insert(&ui_hash, ikey, &fidx->uih_link);
     383                futex_up(&used_futex);
    369384        }
    370385
     
    382397        };
    383398
     399        futex_down(&used_futex);
    384400        l = hash_table_find(&ui_hash, ikey);
     401        futex_up(&used_futex);
    385402        if (l) {
    386403                fidx = hash_table_get_instance(l, fat_idx_t, uih_link);
Note: See TracChangeset for help on using the changeset viewer.