Changeset 1be7bee in mainline for uspace/srv/taskman/main.c


Ignore:
Timestamp:
2019-08-07T04:20:30Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
70d28e8
Parents:
fe86d9d
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-10-05 21:17:40)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 04:20:30)
Message:

sysman: Move task retval and waiting logic to taskman (partially)

  • two important sessions: NS and taskman
  • depending on boot task vs spawned task those sessions are initiated differently

Conflicts:

uspace/lib/c/generic/async.c
uspace/lib/c/generic/libc.c
uspace/lib/c/generic/task.c
uspace/lib/c/include/ipc/ns.h
uspace/lib/c/include/task.h
uspace/lib/posix/source/sys/wait.c
uspace/srv/loader/main.c
uspace/srv/ns/ns.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/taskman/main.c

    rfe86d9d r1be7bee  
    3434#include <ipc/taskman.h>
    3535#include <loader/loader.h>
     36#include <macros.h>
    3637#include <ns.h>
    3738#include <stdio.h>
    3839#include <stdlib.h>
    3940
    40 #define NAME "taskman"
     41#include "task.h"
     42#include "taskman.h"
    4143
    4244//TODO move to appropriate header file
     
    5658static void connect_to_loader(ipc_callid_t iid, ipc_call_t *icall)
    5759{
     60        //TODO explain why we don't explicitly accept connection request
    5861        /* Spawn a loader. */
    5962        int rc = loader_spawn("loader");
     
    99102}
    100103
     104static void taskman_ctl_wait(ipc_callid_t iid, ipc_call_t *icall)
     105{
     106        task_id_t id = (task_id_t)
     107            MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
     108        int flags = IPC_GET_ARG3(*icall);
     109
     110        wait_for_task(id, flags, iid, icall);
     111}
     112
     113static void taskman_ctl_retval(ipc_callid_t iid, ipc_call_t *icall)
     114{
     115        printf("%s:%i\n", __func__, __LINE__);
     116        int rc = task_set_retval(icall);
     117        async_answer_0(iid, rc);
     118}
     119
     120static void control_connection_loop(void)
     121{
     122        while (true) {
     123                ipc_call_t call;
     124                ipc_callid_t callid = async_get_call(&call);
     125
     126                if (!IPC_GET_IMETHOD(call)) {
     127                        /* Client disconnected */
     128                        break;
     129                }
     130
     131                switch (IPC_GET_IMETHOD(call)) {
     132                case TASKMAN_WAIT:
     133                        taskman_ctl_wait(callid, &call);
     134                        break;
     135                case TASKMAN_RETVAL:
     136                        taskman_ctl_retval(callid, &call);
     137                        break;
     138                default:
     139                        async_answer_0(callid, ENOENT);
     140                }
     141        }
     142}
     143
     144static void control_connection(ipc_callid_t iid, ipc_call_t *icall)
     145{
     146        /* First, accept connection */
     147        async_answer_0(iid, EOK);
     148
     149        // TODO register task to hash table
     150        control_connection_loop();
     151}
     152
    101153static void loader_callback(ipc_callid_t iid, ipc_call_t *icall)
    102154{
     
    134186                loader_to_ns(iid, icall);
    135187                break;
     188        case TASKMAN_CONTROL:
     189                control_connection(iid, icall);
     190                // ---- interrupt here ----
     191                //   implement control connection body (setup wait)
     192                // ------------------------
     193                break;
    136194        default:
    137195                /* Unknown interface */
     
    146204        case TASKMAN_LOADER_CALLBACK:
    147205                loader_callback(iid, icall);
     206                // TODO register task to hashtable
     207                control_connection_loop();
    148208                break;
    149209        default:
     
    161221
    162222        prodcons_initialize(&sess_queue);
     223        int rc = task_init();
     224        if (rc != EOK) {
     225                return rc;
     226        }
    163227
    164228        /* We're service too */
    165         int rc = service_register(SERVICE_TASKMAN);
     229        rc = service_register(SERVICE_TASKMAN);
    166230        if (rc != EOK) {
    167231                printf("Cannot register at naming service (%i).", rc);
Note: See TracChangeset for help on using the changeset viewer.