Ignore:
Timestamp:
2018-07-20T16:27:20Z (7 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/private/fibril.h

    r7137f74c r514d561  
    4242        context_t ctx;
    4343
     44        uspace_arg_t uarg;
    4445        link_t link;
    4546        void *stack;
     47        size_t stack_size;
    4648        void *arg;
    4749        errno_t (*func)(void *);
     
    5153        errno_t retval;
    5254
    53         fibril_owner_info_t *waits_for;
     55        fibril_t *thread_ctx;
    5456
    55         atomic_t futex_locks;
     57        bool is_running : 1;
    5658        bool is_writer : 1;
    5759        /* In some places, we use fibril structs that can't be freed. */
    5860        bool is_freeable : 1;
     61
     62        /* Debugging stuff. */
     63        atomic_t futex_locks;
     64        fibril_owner_info_t *waits_for;
     65        fibril_event_t *sleep_event;
    5966};
    60 
    61 typedef enum {
    62         FIBRIL_PREEMPT,
    63         FIBRIL_FROM_BLOCKED,
    64         FIBRIL_FROM_MANAGER,
    65         FIBRIL_FROM_DEAD
    66 } fibril_switch_type_t;
    6767
    6868extern fibril_t *fibril_alloc(void);
    6969extern void fibril_setup(fibril_t *);
    70 extern void fibril_teardown(fibril_t *f, bool locked);
    71 extern int fibril_switch(fibril_switch_type_t stype);
    72 extern void fibril_add_manager(fid_t fid);
    73 extern void fibril_remove_manager(void);
     70extern void fibril_teardown(fibril_t *f);
    7471extern fibril_t *fibril_self(void);
    7572
     73extern void __fibrils_init(void);
     74
    7675#endif
Note: See TracChangeset for help on using the changeset viewer.