Changeset 01b87dc5 in mainline


Ignore:
Timestamp:
2010-12-21T16:07:59Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
61cc94e
Parents:
c81b6f2
Message:

Deploy the fibril_{mutex,rwlock}_[*_]is_locked() functions in a few locations.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/packet/generic/packet_server.c

    rc81b6f2 r01b87dc5  
    135135/** Creates a new packet of dimensions at least as given.
    136136 *
    137  * Should be used only when the global data are locked.
    138  *
    139137 * @param[in] length    The total length of the packet, including the header,
    140138 *                      the addresses and the data of the packet.
     
    153151        packet_t *packet;
    154152        int rc;
     153
     154        assert(fibril_mutex_is_locked(&ps_globals.lock));
    155155
    156156        // already locked
     
    233233/** Release the packet and returns it to the appropriate free packet queue.
    234234 *
    235  * Should be used only when the global data are locked.
    236  *
    237235 * @param[in] packet    The packet to be released.
    238236 *
     
    242240        int index;
    243241        int result;
     242
     243        assert(fibril_mutex_is_locked(&ps_globals.lock));
    244244
    245245        for (index = 0; (index < FREE_QUEUES_COUNT - 1) &&
  • uspace/srv/devman/devman.c

    rc81b6f2 r01b87dc5  
    384384        printf(NAME ": create_root_node\n");
    385385
     386        fibril_rwlock_write_lock(&tree->rwlock);
    386387        node = create_dev_node();
    387388        if (node != NULL) {
     
    393394                tree->root_node = node;
    394395        }
     396        fibril_rwlock_write_unlock(&tree->rwlock);
    395397
    396398        return node != NULL;
     
    455457/** Start a driver
    456458 *
    457  * The driver's mutex is assumed to be locked.
    458  *
    459459 * @param drv           The driver's structure.
    460460 * @return              True if the driver's task is successfully spawned, false
     
    465465        int rc;
    466466
     467        assert(fibril_mutex_is_locked(&drv->driver_mutex));
     468       
    467469        printf(NAME ": start_driver '%s'\n", drv->name);
    468470       
     
    859861/** Find the device node structure of the device witch has the specified handle.
    860862 *
    861  * Device tree's rwlock should be held at least for reading.
    862  *
    863863 * @param tree          The device tree where we look for the device node.
    864864 * @param handle        The handle of the device.
     
    868868{
    869869        unsigned long key = handle;
    870         link_t *link = hash_table_find(&tree->devman_devices, &key);
     870        link_t *link;
     871       
     872        assert(fibril_rwlock_is_locked(&tree->rwlock));
     873       
     874        link = hash_table_find(&tree->devman_devices, &key);
    871875        return hash_table_get_instance(link, node_t, devman_link);
    872876}
     
    924928/** Insert new device into device tree.
    925929 *
    926  * The device tree's rwlock should be already held exclusively when calling this
    927  * function.
    928  *
    929930 * @param tree          The device tree.
    930931 * @param node          The newly added device node.
     
    941942        assert(tree != NULL);
    942943        assert(dev_name != NULL);
     944        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    943945       
    944946        node->name = dev_name;
  • uspace/srv/devmap/devmap.c

    rc81b6f2 r01b87dc5  
    4646#include <str.h>
    4747#include <ipc/devmap.h>
     48#include <assert.h>
    4849
    4950#define NAME          "devmap"
     
    208209}
    209210
    210 /** Find namespace with given name.
    211  *
    212  * The devices_list_mutex should be already held when
    213  * calling this function.
    214  *
    215  */
     211/** Find namespace with given name. */
    216212static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    217213{
    218214        link_t *item;
     215       
     216        assert(fibril_mutex_is_locked(&devices_list_mutex));
     217       
    219218        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    220219                devmap_namespace_t *namespace =
     
    229228/** Find namespace with given handle.
    230229 *
    231  * The devices_list_mutex should be already held when
    232  * calling this function.
    233  *
    234230 * @todo: use hash table
    235231 *
     
    238234{
    239235        link_t *item;
     236       
     237        assert(fibril_mutex_is_locked(&devices_list_mutex));
     238       
    240239        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    241240                devmap_namespace_t *namespace =
     
    248247}
    249248
    250 /** Find device with given name.
    251  *
    252  * The devices_list_mutex should be already held when
    253  * calling this function.
    254  *
    255  */
     249/** Find device with given name. */
    256250static devmap_device_t *devmap_device_find_name(const char *ns_name,
    257251    const char *name)
    258252{
    259253        link_t *item;
     254       
     255        assert(fibril_mutex_is_locked(&devices_list_mutex));
     256       
    260257        for (item = devices_list.next; item != &devices_list; item = item->next) {
    261258                devmap_device_t *device =
     
    271268/** Find device with given handle.
    272269 *
    273  * The devices_list_mutex should be already held when
    274  * calling this function.
    275  *
    276270 * @todo: use hash table
    277271 *
     
    280274{
    281275        link_t *item;
     276       
     277        assert(fibril_mutex_is_locked(&devices_list_mutex));
     278       
    282279        for (item = devices_list.next; item != &devices_list; item = item->next) {
    283280                devmap_device_t *device =
     
    290287}
    291288
    292 /** Create a namespace (if not already present)
    293  *
    294  * The devices_list_mutex should be already held when
    295  * calling this function.
    296  *
    297  */
     289/** Create a namespace (if not already present). */
    298290static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
    299291{
    300         devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name);
     292        devmap_namespace_t *namespace;
     293       
     294        assert(fibril_mutex_is_locked(&devices_list_mutex));
     295       
     296        namespace = devmap_namespace_find_name(ns_name);
    301297        if (namespace != NULL)
    302298                return namespace;
     
    323319}
    324320
    325 /** Destroy a namespace (if it is no longer needed)
    326  *
    327  * The devices_list_mutex should be already held when
    328  * calling this function.
    329  *
    330  */
     321/** Destroy a namespace (if it is no longer needed). */
    331322static void devmap_namespace_destroy(devmap_namespace_t *namespace)
    332323{
     324        assert(fibril_mutex_is_locked(&devices_list_mutex));
     325
    333326        if (namespace->refcnt == 0) {
    334327                list_remove(&(namespace->namespaces));
     
    339332}
    340333
    341 /** Increase namespace reference count by including device
    342  *
    343  * The devices_list_mutex should be already held when
    344  * calling this function.
    345  *
    346  */
     334/** Increase namespace reference count by including device. */
    347335static void devmap_namespace_addref(devmap_namespace_t *namespace,
    348336    devmap_device_t *device)
    349337{
     338        assert(fibril_mutex_is_locked(&devices_list_mutex));
     339
    350340        device->namespace = namespace;
    351341        namespace->refcnt++;
    352342}
    353343
    354 /** Decrease namespace reference count
    355  *
    356  * The devices_list_mutex should be already held when
    357  * calling this function.
    358  *
    359  */
     344/** Decrease namespace reference count. */
    360345static void devmap_namespace_delref(devmap_namespace_t *namespace)
    361346{
     347        assert(fibril_mutex_is_locked(&devices_list_mutex));
     348
    362349        namespace->refcnt--;
    363350        devmap_namespace_destroy(namespace);
    364351}
    365352
    366 /** Unregister device and free it
    367  *
    368  * The devices_list_mutex should be already held when
    369  * calling this function.
    370  *
    371  */
     353/** Unregister device and free it. */
    372354static void devmap_device_unregister_core(devmap_device_t *device)
    373355{
     356        assert(fibril_mutex_is_locked(&devices_list_mutex));
     357
    374358        devmap_namespace_delref(device->namespace);
    375359        list_remove(&(device->devices));
Note: See TracChangeset for help on using the changeset viewer.