Changeset 012dd8e in mainline for uspace/lib/c/generic/ns.c


Ignore:
Timestamp:
2019-08-07T09:15:30Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
e8747bd8
Parents:
780c8ce
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-01 00:08:04)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 09:15:30)
Message:

taskman: Handle INIT_TASKS as tasks spawned by loader

  • everyone is connected to its spawner, except for INIT_TASKS, they are connected to taskman (first binary)
  • taskman is now aware even of INIT_TASKS and taskman itself
  • refactored taskman handshake — NS session is created lazily
  • refactored async.c with usage of create_session
  • changed EINVAL to EINTR on lost waits
  • removed TODOs from taskman and related libc TODOs

Conflicts:

abi/include/abi/ipc/methods.h
boot/Makefile.common
uspace/lib/c/generic/async.c
uspace/lib/c/generic/libc.c
uspace/lib/c/generic/loader.c
uspace/lib/c/generic/ns.c
uspace/lib/c/generic/private/async.h
uspace/lib/c/generic/private/taskman.h
uspace/lib/c/generic/task.c
uspace/lib/c/include/async.h
uspace/lib/c/include/task.h
uspace/srv/loader/main.c
uspace/srv/ns/ns.c

File:
1 edited

Legend:

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

    r780c8ce r012dd8e  
    3838#include <macros.h>
    3939#include <errno.h>
    40 #include "private/ns.h"
     40
     41#include "private/taskman.h"
     42
     43static async_sess_t *session_ns = NULL;
     44
     45static async_exch_t *ns_exchange_begin(void)
     46{
     47        /* Lazily connect to our NS */
     48        if (session_ns == NULL) {
     49                session_ns = taskman_session_ns();
     50        }
     51
     52        async_exch_t *exch = async_exchange_begin(session_ns);
     53        return exch;
     54}
     55
     56static void ns_exchange_end(async_exch_t *exch)
     57{
     58        async_exchange_end(exch);
     59}
    4160
    4261/*
     
    4968    async_port_handler_t handler, void *data)
    5069{
    51         async_sess_t *sess = get_session_primary();
    52         if (sess == NULL)
    53                 return EIO;
    54 
    5570        port_id_t port;
    5671        errno_t rc = async_create_port(iface, handler, data, &port);
     
    5873                return rc;
    5974
    60         async_exch_t *exch = async_exchange_begin(sess);
     75        async_exch_t *exch = ns_exchange_begin();
    6176
    6277        ipc_call_t answer;
     
    6479        rc = async_connect_to_me(exch, iface, service, 0);
    6580
    66         async_exchange_end(exch);
     81        ns_exchange_end(exch);
    6782
    6883        if (rc != EOK) {
     
    105120async_sess_t *service_connect(service_t service, iface_t iface, sysarg_t arg3)
    106121{
    107         async_sess_t *sess = get_session_primary();
    108         if (sess == NULL)
    109                 return NULL;
    110 
    111         async_exch_t *exch = async_exchange_begin(sess);
     122        async_exch_t *exch = ns_exchange_begin();
    112123        if (exch == NULL)
    113124                return NULL;
    114125
    115         async_sess_t *csess =
     126        async_sess_t *sess =
    116127            async_connect_me_to(exch, iface, service, arg3);
    117         async_exchange_end(exch);
     128        ns_exchange_end(exch);
    118129
    119         if (csess == NULL)
     130        if (sess == NULL)
    120131                return NULL;
    121132
     
    125136         * first argument for non-initial connections.
    126137         */
    127         async_sess_args_set(csess, iface, arg3, 0);
     138        async_sess_args_set(sess, iface, arg3, 0);
    128139
    129140        return csess;
     
    133144    sysarg_t arg3)
    134145{
    135         async_sess_t *sess = get_session_primary();
     146        async_exch_t *exch = ns_exchange_begin();
     147        async_sess_t *sess =
     148            async_connect_me_to_blocking(exch, iface, service, arg3);
     149        ns_exchange_end(exch);
     150
    136151        if (sess == NULL)
    137                 return NULL;
    138 
    139         async_exch_t *exch = async_exchange_begin(sess);
    140         async_sess_t *csess =
    141             async_connect_me_to_blocking(exch, iface, service, arg3);
    142         async_exchange_end(exch);
    143 
    144         if (csess == NULL)
    145152                return NULL;
    146153
     
    150157         * first argument for non-initial connections.
    151158         */
    152         async_sess_args_set(csess, iface, arg3, 0);
     159        async_sess_args_set(sess, iface, arg3, 0);
    153160
    154         return csess;
     161        return sess;
    155162}
    156163
    157164errno_t ns_ping(void)
    158165{
    159         async_sess_t *sess = get_session_primary();
    160         if (sess == NULL)
    161                 return EIO;
    162 
    163         async_exch_t *exch = async_exchange_begin(sess);
     166        async_exch_t *exch = ns_exchange_begin(sess);
    164167        errno_t rc = async_req_0_0(exch, NS_PING);
    165         async_exchange_end(exch);
     168        ns_exchange_end(exch);
    166169
    167170        return rc;
    168171}
    169172
    170 
    171 async_sess_t *get_session_primary(void)
    172 {
    173         async_exch_t *exch;
    174 
    175         if (sess_primary == NULL) {
    176                 exch = async_exchange_begin(&session_primary);
    177                 sess_primary = async_connect_me_to(exch, 0, 0, 0);
    178                 async_exchange_end(exch);
    179                 if (sess_primary == NULL)
    180                         return NULL;
    181         }
    182 
    183         return sess_primary;
    184 }
    185 
    186173/** @}
    187174 */
Note: See TracChangeset for help on using the changeset viewer.