Changeset 3bd1d7d4 in mainline


Ignore:
Timestamp:
2018-06-19T19:48:14Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d7bc09, 8751cf3
Parents:
5c76cc61
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-05-31 18:05:11)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-19 19:48:14)
Message:

async: Use a dedicated futex for client hash table.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async/server.c

    r5c76cc61 r3bd1d7d4  
    240240}
    241241
     242static futex_t client_futex = FUTEX_INITIALIZER;
    242243static hash_table_t client_hash_table;
    243 static hash_table_t conn_hash_table;
    244244
    245245// TODO: lockfree notification_queue?
     
    249249static FIBRIL_SEMAPHORE_INITIALIZE(notification_semaphore, 0);
    250250
     251static sysarg_t notification_avail = 0;
     252
     253/* The remaining structures are guarded by async_futex. */
     254static hash_table_t conn_hash_table;
    251255static LIST_INITIALIZE(timeout_list);
    252 
    253 static sysarg_t notification_avail = 0;
    254256
    255257static size_t client_key_hash(void *key)
     
    339341        client_t *client = NULL;
    340342
    341         futex_down(&async_futex);
     343        futex_lock(&client_futex);
    342344        ht_link_t *link = hash_table_find(&client_hash_table, &client_id);
    343345        if (link) {
     
    345347                atomic_inc(&client->refcnt);
    346348        } else if (create) {
     349                // TODO: move the malloc out of critical section
    347350                client = malloc(sizeof(client_t));
    348351                if (client) {
     
    355358        }
    356359
    357         futex_up(&async_futex);
     360        futex_unlock(&client_futex);
    358361        return client;
    359362}
     
    363366        bool destroy;
    364367
    365         futex_down(&async_futex);
     368        futex_lock(&client_futex);
    366369
    367370        if (atomic_predec(&client->refcnt) == 0) {
     
    371374                destroy = false;
    372375
    373         futex_up(&async_futex);
     376        futex_unlock(&client_futex);
    374377
    375378        if (destroy) {
Note: See TracChangeset for help on using the changeset viewer.