Changeset ae03552e in mainline


Ignore:
Timestamp:
2017-10-07T16:39:45Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a0be5d0
Parents:
e9e24f2
Message:

hcd: get rid of async_usleep

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/hcd.c

    re9e24f2 rae03552e  
    248248
    249249typedef struct {
    250         volatile unsigned done;
     250        fibril_mutex_t done_mtx;
     251        fibril_condvar_t done_cv;
     252        unsigned done;
    251253        int ret;
    252254        size_t size;
     
    258260        assert(d);
    259261        d->ret = ret;
     262        d->size = size;
     263        fibril_mutex_lock(&d->done_mtx);
    260264        d->done = 1;
    261         d->size = size;
     265        fibril_condvar_broadcast(&d->done_cv);
     266        fibril_mutex_unlock(&d->done_mtx);
    262267}
    263268
     
    267272        assert(data);
    268273        d->ret = ret;
     274        fibril_mutex_lock(&d->done_mtx);
    269275        d->done = 1;
     276        fibril_condvar_broadcast(&d->done_cv);
     277        fibril_mutex_unlock(&d->done_mtx);
    270278}
    271279
     
    277285        assert(hcd);
    278286        sync_data_t sd = { .done = 0, .ret = EBUSY, .size = size };
     287        fibril_mutex_initialize(&sd.done_mtx);
     288        fibril_condvar_initialize(&sd.done_cv);
    279289
    280290        const int ret = hcd_send_batch(hcd, target, dir, data, size, setup_data,
     
    284294                return ret;
    285295
    286         while (!sd.done) {
    287                 async_usleep(1000);
    288         }
     296        fibril_mutex_lock(&sd.done_mtx);
     297        while (!sd.done)
     298                fibril_condvar_wait(&sd.done_cv, &sd.done_mtx);
     299        fibril_mutex_unlock(&sd.done_mtx);
    289300
    290301        if (sd.ret == EOK)
Note: See TracChangeset for help on using the changeset viewer.