Changeset d4ec49e in mainline for uspace/lib/c/generic/task.c


Ignore:
Timestamp:
2019-08-07T05:25:59Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
3ea98e8
Parents:
55fe220
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-10-14 23:13:41)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 05:25:59)
Message:

taskman: Implement waiting both for retval and exit
Conflicts:

uspace/lib/c/generic/task.c
uspace/lib/c/include/task.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/task.c

    r55fe220 rd4ec49e  
    128128 *
    129129 * @return EOK on success, else error code.
     130 * @return TODO check this doesn't return EINVAL -- clash with task_wait
    130131 */
    131132static errno_t task_setup_wait(task_id_t id, task_wait_t *wait)
    132133{
    133134        assert(wait->flags);
     135        if (wait->flags & TASK_WAIT_BOTH) {
     136                wait->flags |= (TASK_WAIT_RETVAL | TASK_WAIT_EXIT);
     137        }
     138        wait->tid = id;
    134139        async_exch_t *exch = taskman_exchange_begin();
    135140        if (exch == NULL)
     
    391396 * @param retval Store return value of the task here.
    392397 *
    393  * @return EOK on success, else error code.
     398 * @return EOK on success
     399 * @return EINVAL on lost wait TODO other error codes
    394400 */
    395401errno_t task_wait(task_wait_t *wait, task_exit_t *texit, int *retval)
     
    397403        errno_t rc;
    398404        async_wait_for(wait->aid, &rc);
    399        
    400         if (rc == EOK) {
     405
     406        if (rc == EOK || rc == EINVAL) {
    401407                if (wait->flags & TASK_WAIT_EXIT && texit)
    402408                        *texit = ipc_get_arg1(wait->result);
    403409                if (wait->flags & TASK_WAIT_RETVAL && retval)
    404410                        *retval = ipc_get_arg2(wait->result);
     411               
     412        }
     413
     414        if (rc == EOK) {
     415                /* Is there another wait to be done? Wait for it! */
     416                int old_flags = wait->flags;
     417                wait->flags = ipc_get_arg3(wait->result);
     418                if (wait->flags != 0 && (old_flags & TASK_WAIT_BOTH)) {
     419                        rc = task_setup_wait(wait->tid, wait);
     420                }
     421        } else {
     422                wait->flags = 0;
    405423        }
    406424
Note: See TracChangeset for help on using the changeset viewer.