Changeset add5835 in mainline for uspace/srv/fs/fat/fat_idx.c
- Timestamp:
- 2008-05-17T20:10:54Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e811bde
- Parents:
- 78a1b7b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_idx.c
r78a1b7b radd5835 75 75 static LIST_INITIALIZE(unused_head); 76 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 */ 77 /** Futex protecting the up_hash and ui_hash. */ 86 78 static futex_t used_futex = FUTEX_INITIALIZER; 87 79 … … 353 345 futex_down(&used_futex); 354 346 l = hash_table_find(&up_hash, pkey); 355 futex_up(&used_futex);356 347 if (l) { 357 348 fidx = hash_table_get_instance(l, fat_idx_t, uph_link); … … 359 350 fidx = (fat_idx_t *) malloc(sizeof(fat_idx_t)); 360 351 if (!fidx) { 352 futex_up(&used_futex); 361 353 return NULL; 362 354 } 363 355 if (!fat_idx_alloc(dev_handle, &fidx->index)) { 364 356 free(fidx); 357 futex_up(&used_futex); 365 358 return NULL; 366 359 } … … 373 366 link_initialize(&fidx->uph_link); 374 367 link_initialize(&fidx->uih_link); 368 futex_initialize(&fidx->lock, 1); 375 369 fidx->dev_handle = dev_handle; 376 370 fidx->pfc = pfc; … … 378 372 fidx->nodep = NULL; 379 373 380 futex_down(&used_futex);381 374 hash_table_insert(&up_hash, pkey, &fidx->uph_link); 382 375 hash_table_insert(&ui_hash, ikey, &fidx->uih_link); 383 futex_up(&used_futex); 384 } 376 } 377 futex_down(&fidx->lock); 378 futex_up(&used_futex); 385 379 386 380 return fidx; … … 399 393 futex_down(&used_futex); 400 394 l = hash_table_find(&ui_hash, ikey); 401 futex_up(&used_futex);402 395 if (l) { 403 396 fidx = hash_table_get_instance(l, fat_idx_t, uih_link); 404 } 397 futex_down(&fidx->lock); 398 } 399 futex_up(&used_futex); 405 400 406 401 return fidx;
Note:
See TracChangeset
for help on using the changeset viewer.