Changeset 398c4d7 in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2010-12-01T23:51:29Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c245f16e
Parents:
2edcb63
Message:

More conservative locking in devman

Add mutex guard when accessing driver_t structure during driver assigning.

Added missing async_wait_for and removed extra mutex_unlock.

To speed-up answer time, driver start is done in separate fibril to avoid
blocking IPC connection fibril.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    r2edcb63 r398c4d7  
    520520        fibril_mutex_lock(&driver->driver_mutex);
    521521
    522         phone = ipc_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
     522        phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
    523523
    524524        if (phone < 0) {
     
    583583         * immediately and possibly started here as well.
    584584         */
     585        printf(NAME ": driver %s goes into running state.\n", driver->name);
    585586        driver->state = DRIVER_RUNNING;
    586587
     
    712713                /* TODO handle error */
    713714        }
    714        
     715
    715716        /* Wait for answer from the driver. */
    716717        async_wait_for(req, &rc);
     
    755756        attach_driver(node, drv);
    756757       
     758        fibril_mutex_lock(&drv->driver_mutex);
    757759        if (drv->state == DRIVER_NOT_STARTED) {
    758760                /* Start the driver. */
    759761                start_driver(drv);
    760762        }
    761        
    762         if (drv->state == DRIVER_RUNNING) {
     763        fibril_mutex_unlock(&drv->driver_mutex);
     764       
     765        fibril_mutex_lock(&drv->driver_mutex);
     766        bool is_running = drv->state == DRIVER_RUNNING;
     767        fibril_mutex_unlock(&drv->driver_mutex);
     768
     769        if (is_running) {
    763770                /* Notify the driver about the new device. */
    764                 int phone = ipc_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
     771                int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
    765772                if (phone > 0) {
    766773                        add_device(phone, drv, node, tree);
     
    924931        node->name = dev_name;
    925932        if (!set_dev_path(node, parent)) {
    926                 fibril_rwlock_write_unlock(&tree->rwlock);
    927933                return false;
    928934        }
Note: See TracChangeset for help on using the changeset viewer.