Changeset 1be7bee in mainline for uspace/lib/c/generic/task.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/lib/c/generic/task.c
rfe86d9d r1be7bee 35 35 */ 36 36 37 #include <task.h>38 #include <loader/loader.h>39 #include <stdarg.h>40 #include <str.h>41 #include <ipc/ns.h>42 #include <macros.h>43 37 #include <assert.h> 44 38 #include <async.h> … … 46 40 #include <ns.h> 47 41 #include <stdlib.h> 42 #include <ipc/taskman.h> 48 43 #include <libc.h> 44 #include <loader/loader.h> 45 #include <macros.h> 46 #include <malloc.h> 47 #include <stdarg.h> 48 #include <str.h> 49 #include <task.h> 50 #include <vfs/vfs.h> 49 51 #include "private/ns.h" 50 #include <vfs/vfs.h> 52 #include "private/task.h" 53 54 static async_sess_t *session_taskman = NULL; 51 55 52 56 task_id_t task_get_id(void) … … 64 68 } 65 69 70 static async_exch_t *taskman_exchange_begin(void) 71 { 72 /* Lazy connection */ 73 if (session_taskman == NULL) { 74 // TODO unify exchange mgmt with taskman_handshake/__init 75 session_taskman = service_connect_blocking(EXCHANGE_SERIALIZE, 76 SERVICE_TASKMAN, 77 TASKMAN_CONTROL, 78 0); 79 } 80 81 if (session_taskman == NULL) { 82 return NULL; 83 } 84 85 async_exch_t *exch = async_exchange_begin(session_taskman); 86 return exch; 87 } 88 89 static void taskman_exchange_end(async_exch_t *exch) 90 { 91 async_exchange_end(exch); 92 } 93 66 94 /** Set the task name. 67 95 * … … 88 116 { 89 117 return (errno_t) __SYSCALL1(SYS_TASK_KILL, (sysarg_t) &task_id); 118 } 119 120 /** Setup waiting for a task. 121 * 122 * If the task finishes after this call succeeds, it is guaranteed that 123 * task_wait(wait, &texit, &retval) will return correct return value for 124 * the task. 125 * 126 * @param id ID of the task to setup waiting for. 127 * @param wait Information necessary for the later task_wait call is stored here. 128 * 129 * @return EOK on success, else error code. 130 */ 131 static errno_t task_setup_wait(task_id_t id, task_wait_t *wait) 132 { 133 async_exch_t *exch = taskman_exchange_begin(); 134 if (exch == NULL) 135 return EIO; 136 137 wait->aid = async_send_3(exch, TASKMAN_WAIT, LOWER32(id), UPPER32(id), 138 wait->flags, &wait->result); 139 taskman_exchange_end(exch); 140 141 return EOK; 90 142 } 91 143 … … 312 364 } 313 365 314 /** Setup waiting for a task.315 *316 * If the task finishes after this call succeeds, it is guaranteed that317 * task_wait(wait, &texit, &retval) will return correct return value for318 * the task.319 *320 * @param id ID of the task to setup waiting for.321 * @param wait Information necessary for the later task_wait call is stored here.322 *323 * @return EOK on success, else error code.324 */325 errno_t task_setup_wait(task_id_t id, task_wait_t *wait)326 {327 async_sess_t *sess_ns = get_session_primary();328 if (sess_ns == NULL)329 return EIO;330 331 async_exch_t *exch = async_exchange_begin(sess_ns);332 333 wait->aid = async_send_2(exch, NS_TASK_WAIT, LOWER32(id), UPPER32(id),334 &wait->result);335 async_exchange_end(exch);336 337 return EOK;338 }339 340 366 /** Cancel waiting for a task. 341 367 * … … 391 417 * 392 418 * @param id ID of the task to wait for. 419 * @param flags Specify for which task output we wait 393 420 * @param texit Store type of task exit here. 394 421 * @param retval Store return value of the task here. … … 396 423 * @return EOK on success, else error code. 397 424 */ 398 errno_t task_wait_task_id(task_id_t id, task_exit_t *texit, int *retval)425 errno_t task_wait_task_id(task_id_t id, int flags, task_exit_t *texit, int *retval) 399 426 { 400 427 task_wait_t wait; 428 wait.flags = flags; 401 429 errno_t rc = task_setup_wait(id, &wait); 430 402 431 if (rc != EOK) 403 432 return rc; … … 408 437 errno_t task_retval(int val) 409 438 { 410 async_ sess_t *sess_ns = get_session_primary();411 if ( sess_ns== NULL)439 async_exch_t *exch = taskman_exchange_begin(); 440 if (exch == NULL) 412 441 return EIO; 413 442 414 async_exch_t *exch = async_exchange_begin(sess_ns); 415 errno_t rc = (errno_t) async_req_1_0(exch, NS_RETVAL, val); 416 async_exchange_end(exch); 417 443 int rc = (int) async_req_1_0(exch, TASKMAN_RETVAL, val); 444 taskman_exchange_end(exch); 445 418 446 return rc; 419 447 } 420 448 449 450 void __task_init(async_sess_t *sess) 451 { 452 assert(session_taskman == NULL); 453 session_taskman = sess; 454 } 455 421 456 /** @} 422 457 */
Note:
See TracChangeset
for help on using the changeset viewer.