Changeset 1be7bee in mainline for uspace/srv/taskman/main.c
- Timestamp:
- 2019-08-07T04:20:30Z (6 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/taskman/main.c
rfe86d9d r1be7bee 34 34 #include <ipc/taskman.h> 35 35 #include <loader/loader.h> 36 #include <macros.h> 36 37 #include <ns.h> 37 38 #include <stdio.h> 38 39 #include <stdlib.h> 39 40 40 #define NAME "taskman" 41 #include "task.h" 42 #include "taskman.h" 41 43 42 44 //TODO move to appropriate header file … … 56 58 static void connect_to_loader(ipc_callid_t iid, ipc_call_t *icall) 57 59 { 60 //TODO explain why we don't explicitly accept connection request 58 61 /* Spawn a loader. */ 59 62 int rc = loader_spawn("loader"); … … 99 102 } 100 103 104 static 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 113 static 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 120 static 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 144 static 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 101 153 static void loader_callback(ipc_callid_t iid, ipc_call_t *icall) 102 154 { … … 134 186 loader_to_ns(iid, icall); 135 187 break; 188 case TASKMAN_CONTROL: 189 control_connection(iid, icall); 190 // ---- interrupt here ---- 191 // implement control connection body (setup wait) 192 // ------------------------ 193 break; 136 194 default: 137 195 /* Unknown interface */ … … 146 204 case TASKMAN_LOADER_CALLBACK: 147 205 loader_callback(iid, icall); 206 // TODO register task to hashtable 207 control_connection_loop(); 148 208 break; 149 209 default: … … 161 221 162 222 prodcons_initialize(&sess_queue); 223 int rc = task_init(); 224 if (rc != EOK) { 225 return rc; 226 } 163 227 164 228 /* We're service too */ 165 intrc = service_register(SERVICE_TASKMAN);229 rc = service_register(SERVICE_TASKMAN); 166 230 if (rc != EOK) { 167 231 printf("Cannot register at naming service (%i).", rc);
Note:
See TracChangeset
for help on using the changeset viewer.