Changeset 514d561 in mainline for uspace/lib/c/generic/private/async.h


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/async.h

    r7137f74c r514d561  
    4242#include <sys/time.h>
    4343#include <stdbool.h>
    44 
    45 /** Structures of this type are used to track the timeout events. */
    46 typedef struct {
    47         /** If true, this struct is in the timeout list. */
    48         bool inlist;
    49 
    50         /** Timeout list link. */
    51         link_t link;
    52 
    53         /** If true, we have timed out. */
    54         bool occurred;
    55 
    56         /** Expiration time. */
    57         struct timeval expires;
    58 } to_event_t;
    59 
    60 /** Structures of this type are used to track the wakeup events. */
    61 typedef struct {
    62         /** If true, this struct is in a synchronization object wait queue. */
    63         bool inlist;
    64 
    65         /** Wait queue linkage. */
    66         link_t link;
    67 } wu_event_t;
    68 
    69 /** Structures of this type represent a waiting fibril. */
    70 typedef struct {
    71         /** Identification of and link to the waiting fibril. */
    72         fid_t fid;
    73 
    74         /** If true, this fibril is currently active. */
    75         bool active;
    76 
    77         /** Timeout wait data. */
    78         to_event_t to_event;
    79         /** Wakeup wait data. */
    80         wu_event_t wu_event;
    81 } awaiter_t;
    8244
    8345/** Session data */
     
    13294};
    13395
    134 extern void awaiter_initialize(awaiter_t *);
    135 
    13696extern void __async_server_init(void);
    13797extern void __async_client_init(void);
    13898extern void __async_ports_init(void);
    139 extern void async_insert_timeout(awaiter_t *);
    14099
    141100extern errno_t async_create_port_internal(iface_t, async_port_handler_t,
Note: See TracChangeset for help on using the changeset viewer.