Changeset c07af37 in mainline
- Timestamp:
- 2009-06-15T20:53:18Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef8bcc6
- Parents:
- af7383f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
raf7383f rc07af37 46 46 #include <string.h> 47 47 #include <ipc/devmap.h> 48 #include <assert.h> 48 49 49 50 #define NAME "devmap" … … 95 96 LIST_INITIALIZE(pending_req); 96 97 98 static bool pending_new_dev = false; 99 static FIBRIL_CONDVAR_INITIALIZE(pending_cv); 100 97 101 /* Locking order: 98 102 * drivers_list_mutex … … 175 179 176 180 /** 177 *178 181 * Unregister device and free it. It's assumed that driver's device list is 179 182 * already locked. 180 *181 183 */ 182 184 static int devmap_device_unregister_core(devmap_device_t *device) … … 192 194 193 195 /** 194 *195 196 * Read info about new driver and add it into linked list of registered 196 197 * drivers. 197 *198 198 */ 199 199 static void devmap_driver_register(devmap_driver_t **odriver) … … 350 350 { 351 351 link_t *cur; 352 352 353 353 loop: 354 fibril_mutex_lock(&devices_list_mutex); 355 while (!pending_new_dev) 356 fibril_condvar_wait(&pending_cv, &devices_list_mutex); 357 rescan: 354 358 for (cur = pending_req.next; cur != &pending_req; cur = cur->next) { 355 359 pending_req_t *pr = list_get_instance(cur, pending_req_t, link); … … 365 369 free(pr); 366 370 367 goto loop; 368 } 371 goto rescan; 372 } 373 pending_new_dev = false; 374 fibril_mutex_unlock(&devices_list_mutex); 375 goto loop; 369 376 } 370 377 … … 446 453 447 454 fibril_mutex_unlock(&device->driver->devices_mutex); 455 pending_new_dev = true; 456 fibril_condvar_signal(&pending_cv); 448 457 fibril_mutex_unlock(&devices_list_mutex); 449 458 … … 531 540 name[size] = '\0'; 532 541 542 fibril_mutex_lock(&devices_list_mutex); 543 533 544 /* 534 545 * Find device name in linked list of known devices. … … 544 555 pending_req_t *pr = (pending_req_t *) malloc(sizeof(pending_req_t)); 545 556 if (!pr) { 557 fibril_mutex_unlock(&devices_list_mutex); 546 558 ipc_answer_0(iid, ENOMEM); 547 559 free(name); … … 552 564 pr->callid = iid; 553 565 list_append(&pr->link, &pending_req); 566 fibril_mutex_unlock(&devices_list_mutex); 554 567 return; 555 568 } … … 557 570 ipc_answer_0(iid, ENOENT); 558 571 free(name); 559 return; 560 } 572 fibril_mutex_unlock(&devices_list_mutex); 573 return; 574 } 575 fibril_mutex_unlock(&devices_list_mutex); 561 576 562 577 ipc_answer_1(iid, EOK, dev->handle); … … 660 675 * 661 676 */ 662 static bool devmap_init( )677 static bool devmap_init(void) 663 678 { 664 679 /* Create NULL device entry */ … … 819 834 } 820 835 821 /* Set a handler of incomming connections and 822 pending operations */ 823 async_set_pending(process_pending_lookup); 836 /* Set a handler of incomming connections */ 824 837 async_set_client_connection(devmap_connection); 838 839 /* Create a fibril for handling pending device lookups */ 840 fid_t fid = fibril_create(process_pending_lookup, NULL); 841 assert(fid); 842 fibril_add_ready(fid); 825 843 826 844 /* Register device mapper at naming service */
Note:
See TracChangeset
for help on using the changeset viewer.