Changeset 102f641 in mainline for uspace/srv/taskman
- Timestamp:
- 2019-09-02T19:01:50Z (6 years ago)
- Children:
- 25697163
- Parents:
- 241f1985
- Location:
- uspace/srv/taskman
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/taskman/event.c
r241f1985 r102f641 167 167 async_answer_1(pr->icall, EINTR, t->exit); 168 168 } else { 169 /* Send both exit status and retval, caller 170 * should know what is valid */ 169 /* 170 * Send both exit status and retval, caller 171 * should know what is valid 172 */ 171 173 async_answer_3(pr->icall, EOK, t->exit, 172 174 t->retval, rest); … … 180 182 } 181 183 182 183 184 list_remove(&pr->link); 184 185 free(pr); … … 233 234 234 235 void wait_for_task(task_id_t id, int flags, ipc_call_t *icall, 235 236 task_id_t waiter_id) 236 237 { 237 238 assert(!(flags & TASK_WAIT_BOTH) || … … 247 248 return; 248 249 } 249 250 250 251 if (t->exit != TASK_EXIT_RUNNING) { 251 252 //TODO are flags BOTH processed correctly here? … … 253 254 return; 254 255 } 255 256 256 257 /* 257 258 * Add request to pending list or reuse existing item for a second … … 274 275 goto finish; 275 276 } 276 277 277 278 link_initialize(&pr->link); 278 279 pr->id = id; … … 305 306 } 306 307 307 308 308 errno_t task_set_retval(task_id_t sender, int retval, bool wait_for_exit) 309 309 { 310 310 errno_t rc = EOK; 311 311 312 312 fibril_rwlock_write_lock(&task_hash_table_lock); 313 313 task_t *t = task_get_by_id(sender); … … 317 317 goto finish; 318 318 } 319 319 320 320 t->retval = retval; 321 321 t->retval_type = wait_for_exit ? RVAL_SET_EXIT : RVAL_SET; 322 322 323 323 event_notify_all(t); 324 324 process_pending_wait(); 325 325 326 326 finish: 327 327 fibril_rwlock_write_unlock(&task_hash_table_lock); -
uspace/srv/taskman/main.c
r241f1985 r102f641 54 54 #include "taskman.h" 55 55 56 57 56 typedef struct { 58 57 link_t link; … … 74 73 { 75 74 DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id); 76 /* We don't accept the connection request, we forward it instead to 77 * freshly spawned loader. */ 75 /* 76 * We don't accept the connection request, we forward it instead to 77 * freshly spawned loader. 78 */ 78 79 errno_t rc = loader_spawn("loader"); 79 80 80 81 if (rc != EOK) { 81 82 async_answer_0(icall, rc); 82 83 return; 83 84 } 84 85 85 86 /* Wait until spawned task presents itself to us. */ 86 87 link_t *link = prodcons_consume(&sess_queue); … … 148 149 /* Used only for connection forwarding -- atomic */ 149 150 session_ns = async_callback_receive(EXCHANGE_ATOMIC); 150 151 151 152 if (session_ns == NULL) { 152 153 rc = ENOENT; … … 218 219 // TODO check that loader is expected, would probably discard prodcons 219 220 // scheme 220 221 221 222 /* Preallocate session container */ 222 223 sess_ref_t *sess_ref = malloc(sizeof(sess_ref_t)); … … 265 266 static bool handle_implicit_call(ipc_call_t *icall) 266 267 { 267 /*DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__,268 IPC_GET_IMETHOD(*icall),269 IPC_GET_ARG1(*icall),270 icall->in_task_id);*/271 272 268 if (ipc_get_imethod(icall) < IPC_FIRST_USER_METHOD) { 273 269 switch (ipc_get_arg1(icall)) { … … 330 326 } 331 327 332 333 334 328 int main(int argc, char *argv[]) 335 329 { … … 358 352 return rc; 359 353 } 360 354 361 355 task_id_t self_id = task_get_id(); 362 356 rc = task_intro(self_id); -
uspace/srv/taskman/task.c
r241f1985 r102f641 46 46 void *arg; 47 47 } walker_context_t; 48 48 49 49 /* 50 50 * Forwards … … 59 59 static size_t ht_task_key_hash(const void *key) 60 60 { 61 return *(task_id_t *)key;61 return *(task_id_t *)key; 62 62 } 63 63 … … 71 71 { 72 72 task_t *ht = hash_table_get_inst(item, task_t, link); 73 return ht->id == *(task_id_t *)key;73 return ht->id == *(task_id_t *)key; 74 74 } 75 75 … … 127 127 128 128 fibril_rwlock_initialize(&task_hash_table_lock); 129 129 130 130 return EOK; 131 131 } … … 145 145 return NULL; 146 146 } 147 147 148 148 task_t *t = hash_table_get_inst(link, task_t, link); 149 149 return t; … … 202 202 goto finish; 203 203 } 204 204 205 205 t = malloc(sizeof(task_t)); 206 206 if (t == NULL) { … … 217 217 hash_table_insert(&task_hash_table, &t->link); 218 218 DPRINTF("%s: %llu\n", __func__, t->id); 219 219 220 220 finish: 221 221 fibril_rwlock_write_unlock(&task_hash_table_lock); … … 223 223 } 224 224 225 226 225 /** 227 226 * @} -
uspace/srv/taskman/task.h
r241f1985 r102f641 43 43 /** What type of retval from the task we have */ 44 44 typedef enum { 45 RVAL_UNSET, /**< unset */ 46 RVAL_SET, /**< retval set, e.g. by server */ 47 RVAL_SET_EXIT /**< retval set, wait for expected task exit */ 45 /* unset */ 46 RVAL_UNSET, 47 48 /* retval set, e.g. by server */ 49 RVAL_SET, 50 51 /* retval set, wait for expected task exit */ 52 RVAL_SET_EXIT 48 53 } retval_t; 49 54 … … 51 56 typedef struct { 52 57 ht_link_t link; 53 54 task_id_t id; /**< Task id. */55 task_exit_t exit; /**< Task's uspace exit status. */56 bool failed; /**< Task failed (task can exit unexpectedly57 even w/out failure). */58 retval_t retval_type; /**< Task returned a value. */59 int retval; /**< The return value. */60 58 61 link_t listeners; /**< Link to listeners list. */ 62 async_sess_t *sess; /**< Session for notifications to task. */ 59 /* Task id. */ 60 task_id_t id; 61 /* Task's uspace exit status. */ 62 task_exit_t exit; 63 /* Task failed (task can exit unexpectedly even w/out failure). */ 64 bool failed; 65 /* Task returned a value. */ 66 retval_t retval_type; 67 /* The return value. */ 68 int retval; 69 /* Link to listeners list. */ 70 link_t listeners; 71 /* Session for notifications to task. */ 72 async_sess_t *sess; 63 73 } task_t; 64 74 65 typedef bool (* 75 typedef bool (*task_walker_t)(task_t *, void *); 66 76 67 77 extern fibril_rwlock_t task_hash_table_lock;
Note:
See TracChangeset
for help on using the changeset viewer.