Changeset 5cd2290 in mainline


Ignore:
Timestamp:
2019-08-07T05:35:46Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
b22b0a94
Parents:
1fb4a49
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-10-18 10:53:14)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 05:35:46)
Message:

taskman: Make use of EVENT_EXIT exit_reason parameter

  • Also improved handling of EVENT_FAULT — it only marks task as failed, waiters are notified after EVENT_EXIT happens.
Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/proc/task_wait.c

    r1fb4a49 r5cd2290  
    262262        TASSERT(rc == EOK);
    263263        TASSERT(task_wait_get(&wait) == 0);
    264         //TASSERT(texit == TASK_EXIT_UNEXPECTED); // TODO resolve this in taskman/kernel
     264        TASSERT(texit == TASK_EXIT_UNEXPECTED);
    265265        TPRINTF("OK\n");
    266266        /* ---- */
  • uspace/srv/taskman/main.c

    r1fb4a49 r5cd2290  
    122122static void task_exit_event(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    123123{
    124         // TODO design substitution for taskmon (monitoring)
    125124        task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
    126         printf("%s:%i from %llu/%i\n", __func__, __LINE__, id, (task_exit_t)arg);
    127         task_terminated(id, (task_exit_t)arg);
     125        exit_reason_t exit_reason = IPC_GET_ARG3(*icall);
     126        printf("%s:%i from %llu/%i\n", __func__, __LINE__, id, exit_reason);
     127        task_terminated(id, exit_reason);
     128}
     129
     130static void task_fault_event(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     131{
     132        task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
     133        printf("%s:%i from %llu\n", __func__, __LINE__, id);
     134        task_failed(id);
    128135}
    129136
     
    254261        }
    255262
    256         rc = async_event_subscribe(EVENT_EXIT, task_exit_event, (void *)TASK_EXIT_NORMAL);
     263        rc = async_event_subscribe(EVENT_EXIT, task_exit_event, NULL);
    257264        if (rc != EOK) {
    258265                printf("Cannot register for exit events (%i).\n", rc);
     
    260267        }
    261268
    262         rc = async_event_subscribe(EVENT_FAULT, task_exit_event, (void *)TASK_EXIT_UNEXPECTED);
     269        rc = async_event_subscribe(EVENT_FAULT, task_fault_event, NULL);
    263270        if (rc != EOK) {
    264271                printf("Cannot register for fault events (%i).\n", rc);
  • uspace/srv/taskman/task.c

    r1fb4a49 r5cd2290  
    6464        ht_link_t link;
    6565       
    66         task_id_t id;        /**< task id. */
    67         task_exit_t exit;    /**< task is done. */
     66        task_id_t id;          /**< task id. */
     67        task_exit_t exit;      /**< task's uspace exit status. */
     68        bool failed;           /**< task failed. */
    6869        retval_t retval_type;  /**< task returned a value. */
    69         int retval;          /**< the return value. */
     70        int retval;            /**< the return value. */
    7071} hashed_task_t;
    7172
     
    302303        ht->id = call->in_task_id;
    303304        ht->exit = TASK_EXIT_RUNNING;
     305        ht->failed = false;
    304306        ht->retval_type = RVAL_UNSET;
    305307        ht->retval = -1;
     
    339341}
    340342
    341 void task_terminated(task_id_t id, task_exit_t texit)
     343void task_terminated(task_id_t id, exit_reason_t exit_reason)
    342344{
    343345        /* Mark task as finished. */
     
    351353       
    352354        /*
    353          * If daemon returns a value and then fails/is killed, it's unexpected
    354          * termination.
     355         * If daemon returns a value and then fails/is killed, it's an
     356         * unexpected termination.
    355357         */
    356         if (ht->retval_type == RVAL_UNSET || texit == TASK_EXIT_UNEXPECTED) {
     358        if (ht->retval_type == RVAL_UNSET || exit_reason == EXIT_REASON_KILLED) {
    357359                ht->exit = TASK_EXIT_UNEXPECTED;
    358         } else {
    359                 ht->exit = texit;
     360        } else if (ht->failed) {
     361                ht->exit = TASK_EXIT_UNEXPECTED;
     362        } else  {
     363                ht->exit = TASK_EXIT_NORMAL;
    360364        }
    361365        process_pending_wait();
    362366
    363367        hash_table_remove_item(&task_hash_table, &ht->link);
     368finish:
     369        fibril_rwlock_write_unlock(&task_hash_table_lock);
     370}
     371
     372void task_failed(task_id_t id)
     373{
     374        /* Mark task as failed. */
     375        fibril_rwlock_write_lock(&task_hash_table_lock);
     376        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     377        if (link == NULL) {
     378                goto finish;
     379        }
     380
     381        hashed_task_t *ht = hash_table_get_inst(link, hashed_task_t, link);
     382       
     383        ht->failed = true;
     384        // TODO design substitution for taskmon (monitoring) = invoke dump utility
     385
    364386finish:
    365387        fibril_rwlock_write_unlock(&task_hash_table_lock);
  • uspace/srv/taskman/task.h

    r1fb4a49 r5cd2290  
    4545
    4646extern int task_intro(ipc_call_t *, bool);
    47 extern void task_terminated(task_id_t, task_exit_t);
     47extern void task_terminated(task_id_t, exit_reason_t);
     48extern void task_failed(task_id_t);
    4849
    4950#endif
Note: See TracChangeset for help on using the changeset viewer.