Changeset 514d561 in mainline for uspace/lib/c/include/fibril.h


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/include/fibril.h

    r7137f74c r514d561  
    3838#include <types/common.h>
    3939#include <time.h>
     40#include <_bits/__noreturn.h>
     41#include <ipc/common.h>
    4042
    4143typedef struct fibril fibril_t;
     
    4547} fibril_owner_info_t;
    4648
    47 typedef sysarg_t fid_t;
     49typedef fibril_t *fid_t;
     50
     51typedef struct {
     52        fibril_t *fibril;
     53} fibril_event_t;
     54
     55#define FIBRIL_EVENT_INIT ((fibril_event_t) {0})
    4856
    4957/** Fibril-local variable specifier */
     
    5260#define FIBRIL_DFLT_STK_SIZE    0
    5361
    54 extern fid_t fibril_create_generic(errno_t (*func)(void *), void *arg, size_t);
    55 extern void fibril_destroy(fid_t fid);
    56 extern void fibril_add_ready(fid_t fid);
     62extern fid_t fibril_create_generic(errno_t (*)(void *), void *, size_t);
     63extern void fibril_destroy(fid_t);
     64extern void fibril_add_ready(fid_t);
    5765extern fid_t fibril_get_id(void);
    5866extern void fibril_yield(void);
     
    7179}
    7280
     81extern void fibril_start(fid_t);
     82extern __noreturn void fibril_exit(long);
     83
     84extern void fibril_wait_for(fibril_event_t *);
     85extern errno_t fibril_wait_timeout(fibril_event_t *, const struct timeval *);
     86extern void fibril_notify(fibril_event_t *);
     87
     88extern errno_t fibril_ipc_wait(ipc_call_t *, const struct timeval *);
     89extern void fibril_ipc_poke(void);
     90
    7391#endif
    7492
Note: See TracChangeset for help on using the changeset viewer.