Changeset c07af37 in mainline


Ignore:
Timestamp:
2009-06-15T20:53:18Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef8bcc6
Parents:
af7383f
Message:

Handle pending lookups using only one fibril.

File:
1 edited

Legend:

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

    raf7383f rc07af37  
    4646#include <string.h>
    4747#include <ipc/devmap.h>
     48#include <assert.h>
    4849
    4950#define NAME  "devmap"
     
    9596LIST_INITIALIZE(pending_req);
    9697
     98static bool pending_new_dev = false;
     99static FIBRIL_CONDVAR_INITIALIZE(pending_cv);
     100
    97101/* Locking order:
    98102 *  drivers_list_mutex
     
    175179
    176180/**
    177  *
    178181 * Unregister device and free it. It's assumed that driver's device list is
    179182 * already locked.
    180  *
    181183 */
    182184static int devmap_device_unregister_core(devmap_device_t *device)
     
    192194
    193195/**
    194  *
    195196 * Read info about new driver and add it into linked list of registered
    196197 * drivers.
    197  *
    198198 */
    199199static void devmap_driver_register(devmap_driver_t **odriver)
     
    350350{
    351351        link_t *cur;
    352        
     352
    353353loop:
     354        fibril_mutex_lock(&devices_list_mutex);
     355        while (!pending_new_dev)
     356                fibril_condvar_wait(&pending_cv, &devices_list_mutex);
     357rescan:
    354358        for (cur = pending_req.next; cur != &pending_req; cur = cur->next) {
    355359                pending_req_t *pr = list_get_instance(cur, pending_req_t, link);
     
    365369                free(pr);
    366370               
    367                 goto loop;
    368         }
     371                goto rescan;
     372        }
     373        pending_new_dev = false;
     374        fibril_mutex_unlock(&devices_list_mutex);
     375        goto loop;
    369376}
    370377
     
    446453       
    447454        fibril_mutex_unlock(&device->driver->devices_mutex);
     455        pending_new_dev = true;
     456        fibril_condvar_signal(&pending_cv);
    448457        fibril_mutex_unlock(&devices_list_mutex);
    449458       
     
    531540        name[size] = '\0';
    532541       
     542        fibril_mutex_lock(&devices_list_mutex);
     543
    533544        /*
    534545         * Find device name in linked list of known devices.
     
    544555                        pending_req_t *pr = (pending_req_t *) malloc(sizeof(pending_req_t));
    545556                        if (!pr) {
     557                                fibril_mutex_unlock(&devices_list_mutex);
    546558                                ipc_answer_0(iid, ENOMEM);
    547559                                free(name);
     
    552564                        pr->callid = iid;
    553565                        list_append(&pr->link, &pending_req);
     566                        fibril_mutex_unlock(&devices_list_mutex);
    554567                        return;
    555568                }
     
    557570                ipc_answer_0(iid, ENOENT);
    558571                free(name);
    559                 return;
    560         }
     572                fibril_mutex_unlock(&devices_list_mutex);
     573                return;
     574        }
     575        fibril_mutex_unlock(&devices_list_mutex);
    561576       
    562577        ipc_answer_1(iid, EOK, dev->handle);
     
    660675 *
    661676 */
    662 static bool devmap_init()
     677static bool devmap_init(void)
    663678{
    664679        /* Create NULL device entry */
     
    819834        }
    820835       
    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 */
    824837        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);
    825843       
    826844        /* Register device mapper at naming service */
Note: See TracChangeset for help on using the changeset viewer.