Changeset 1be7bee in mainline for uspace/lib/c/generic
- 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)
- Location:
- uspace/lib/c/generic
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/client.c
rfe86d9d r1be7bee 174 174 175 175 if (session != NULL) { 176 // TODO extract common part with async_connect_me_to 176 177 session_ns->iface = 0; 177 178 session->mgmt = EXCHANGE_ATOMIC; … … 195 196 196 197 /** Initialize the async framework. 197 * 198 */ 199 void __async_client_init(async_sess_t *session) 198 * @param arg_session_primary Primary session (to naming service). 199 * 200 */ 201 void __async_client_init(async_sess_t *arg_session_primary) 200 202 { 201 203 if (fibril_rmutex_initialize(&message_mutex) != EOK) 202 204 abort(); 203 205 204 if ( session== NULL) {206 if (arg_session_primary == NULL) { 205 207 session_primary = create_session_primary(); 206 208 } else { 207 session_primary = session;209 session_primary = arg_session_primary; 208 210 } 209 211 -
uspace/lib/c/generic/libc.c
rfe86d9d r1be7bee 48 48 #include "private/libc.h" 49 49 #include "private/async.h" 50 #include "private/malloc.h"51 50 #include "private/io.h" 52 51 #include "private/fibril.h" 52 #include "private/malloc.h" 53 #include "private/ns.h" // TODO maybe better filename for session_primary 54 #include "private/task.h" 55 53 56 54 57 #ifdef CONFIG_RTLD … … 108 111 if (__pcb == NULL) { 109 112 __async_client_init(NULL); 113 __task_init(NULL); 110 114 } else { 111 115 __async_client_init(__pcb->session_primary); 116 __task_init(__pcb->session_taskman); 112 117 } 113 118 __async_ports_init(); -
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.