Changeset 514d561 in mainline for uspace/lib/c/generic/rcu.c


Ignore:
Timestamp:
2018-07-20T16:27:20Z (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:
05208d9
Parents:
7137f74c
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-19 21:52:47)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-20 16:27:20)
Message:

Fibril/async implementation overhaul.

This commit marks the move towards treating the fibril library as a mere
implementation of a generic threading interface. Understood as a layer that
wraps the kernel threads, we not only have to wrap threading itself, but also
every syscall that blocks the kernel thread (by blocking, we mean thread not
doing useful work until an external event happens — e.g. locking a kernel
mutex or thread sleep is understood as blocking, but an as_area_create() is not,
despite potentially taking a long time to complete).

Consequently, we implement fibril_ipc_wait() as a fibril-native wrapper for
kernel's ipc_wait(), and also implement timer functionality like timeouts
as part of the fibril library. This removes the interdependency between fibril
implementation and the async framework — in theory, the fibril API could be
reimplemented as a simple 1:1 shim, and the async framework would continue
working normally (note that the current implementation of loader complicates
this).

To better isolate the fibril internals from the implementation of high-level
synchronization, a fibril_event_t is added. This object conceptually acts
like a single slot wait queue. All other synchronization is implemented in
terms of this primitive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/rcu.c

    r7137f74c r514d561  
    115115
    116116typedef struct blocked_fibril {
    117         fid_t id;
     117        fibril_event_t unblock;
    118118        link_t link;
    119119        bool is_ready;
     
    218218}
    219219
    220 /** Delimits the start of an RCU reader critical section. */
     220/** Delimits the end of an RCU reader critical section. */
    221221void rcu_read_unlock(void)
    222222{
     
    361361        if (rcu.sync_lock.locked) {
    362362                blocked_fibril_t blocked_fib;
    363                 blocked_fib.id = fibril_get_id();
     363                blocked_fib.unblock = FIBRIL_EVENT_INIT;
    364364
    365365                list_append(&blocked_fib.link, &rcu.sync_lock.blocked_fibrils);
     
    368368                        blocked_fib.is_ready = false;
    369369                        fibril_rmutex_unlock(&rcu.sync_lock.mutex);
    370                         futex_lock(&async_futex);
    371                         fibril_switch(FIBRIL_FROM_BLOCKED);
    372                         futex_unlock(&async_futex);
     370                        fibril_wait_for(&blocked_fib.unblock);
    373371                        fibril_rmutex_lock(&rcu.sync_lock.mutex);
    374372                } while (rcu.sync_lock.locked);
     
    393391                if (!blocked_fib->is_ready) {
    394392                        blocked_fib->is_ready = true;
    395                         fibril_add_ready(blocked_fib->id);
     393                        fibril_notify(&blocked_fib->unblock);
    396394                }
    397395        }
Note: See TracChangeset for help on using the changeset viewer.