Changeset 4ff66ae in mainline


Ignore:
Timestamp:
2019-08-07T11:18:35Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
87a31ef2
Parents:
bb57a00
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-11-13 03:13:03)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-07 11:18:35)
Message:

taskman: Bind events dump to register handler

  • So that no events are processed twice or omitted.
Location:
uspace
Files:
11 edited

Legend:

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

    rbb57a00 r4ff66ae  
    111111        int rc;
    112112
    113         rc = task_register_event_handler(task_event_handler);
     113        rc = task_register_event_handler(task_event_handler, false);
    114114        TASSERT(rc == EOK);
    115115
  • uspace/lib/c/generic/task_event.c

    rbb57a00 r4ff66ae  
    8383 * Blocks, calls handler in another fibril
    8484 */
    85 int task_register_event_handler(task_event_handler_t handler)
     85int task_register_event_handler(task_event_handler_t handler, bool past_events)
    8686{
    8787        /*
     
    9595
    9696        async_exch_t *exch = taskman_exchange_begin();
    97         aid_t req = async_send_0(exch, TASKMAN_EVENT_CALLBACK, NULL);
     97        aid_t req = async_send_1(exch, TASKMAN_EVENT_CALLBACK, past_events, NULL);
    9898
    9999        int rc = async_connect_to_me(exch, 0, 0, 0, taskman_event_conn, NULL);
  • uspace/lib/c/generic/taskman.c

    rbb57a00 r4ff66ae  
    127127 */
    128128
    129 int taskman_dump_events(void)
    130 {
    131         assert(session_taskman);
    132 
    133         async_exch_t *exch = async_exchange_begin(session_taskman);
    134         int rc = async_req_0_0(exch, TASKMAN_DUMP_EVENTS);
    135         taskman_exchange_end(exch);
    136 
    137         return rc;
    138 }
    139 
    140129async_sess_t *taskman_get_session(void)
    141130{
  • uspace/lib/c/include/ipc/taskman.h

    rbb57a00 r4ff66ae  
    4444        TASKMAN_EVENT_CALLBACK,
    4545        TASKMAN_NEW_TASK,
    46         TASKMAN_I_AM_NS,
    47         TASKMAN_DUMP_EVENTS
     46        TASKMAN_I_AM_NS
    4847} taskman_request_t;
    4948
  • uspace/lib/c/include/taskman.h

    rbb57a00 r4ff66ae  
    4040#endif
    4141
    42 extern int taskman_dump_events(void);
    43 
    4442/* Internal functions to be used by loader only */
    4543#ifndef TASKMAN_DISABLE_ASYNC
  • uspace/srv/sysman/main.c

    rbb57a00 r4ff66ae  
    215215        sysman_events_init();
    216216        job_queue_init();
    217         sm_task_init();
    218217
    219218        /*
     
    246245        }
    247246
    248         /* We're almost ready, scan for boot time tasks */
    249         rc = taskman_dump_events();
     247        /* Start listening task events and scan boot time tasks */
     248        rc = sm_task_start();
    250249        if (rc != EOK) {
    251250                sysman_log(LVL_FATAL,
  • uspace/srv/sysman/sm_task.c

    rbb57a00 r4ff66ae  
    206206}
    207207
    208 int sm_task_init(void)
    209 {
    210         int rc = task_register_event_handler(&sm_task_event_handler);
    211 
    212         //TODO dump taskman info for boot time tasks
     208int sm_task_start(void)
     209{
     210        int rc = task_register_event_handler(&sm_task_event_handler, true);
    213211        return rc;
    214212}
  • uspace/srv/sysman/sm_task.h

    rbb57a00 r4ff66ae  
    3333typedef struct sm_task_event sm_task_event_t;
    3434
    35 extern int sm_task_init(void);
     35extern int sm_task_start(void);
    3636
    3737#endif
  • uspace/srv/taskman/event.c

    rbb57a00 r4ff66ae  
    188188}
    189189
    190 int event_register_listener(task_id_t id, async_sess_t *sess)
     190static bool dump_walker(task_t *t, void *arg)
     191{
     192        event_notify(t, arg);
     193        return true;
     194}
     195
     196void event_register_listener(task_id_t id, bool past_events, async_sess_t *sess,
     197    ipc_callid_t iid)
    191198{
    192199        int rc = EOK;
     200        /*
     201         * We have lock of tasks structures so that we can guarantee
     202         * that dump receiver will receive tasks correctly ordered (retval,
     203         * exit updates are serialized via exclusive lock).
     204         */
    193205        fibril_rwlock_write_lock(&task_hash_table_lock);
    194206        fibril_rwlock_write_lock(&listeners_lock);
     
    203215        t->sess = sess;
    204216
     217        /*
     218         * Answer caller first, so that they are not unnecessarily waiting
     219         * while we dump events.
     220         */
     221        async_answer_0(iid, rc);
     222        if (past_events) {
     223                task_foreach(&dump_walker, t->sess);
     224        }
     225
    205226finish:
    206227        fibril_rwlock_write_unlock(&listeners_lock);
    207228        fibril_rwlock_write_unlock(&task_hash_table_lock);
    208         return rc;
    209 }
    210 
    211 static bool dump_walker(task_t *t, void *arg)
    212 {
    213         event_notify(t, arg);
    214         return true;
    215 }
    216 
    217 void dump_events(task_id_t receiver_id, ipc_callid_t iid)
    218 {
    219         int rc = EOK;
    220         /*
    221          * We have shared lock of tasks structures so that we can guarantee
    222          * that dump receiver will receive tasks correctly ordered (retval,
    223          * exit updates are serialized via exclusive lock).
    224          */
    225         fibril_rwlock_read_lock(&task_hash_table_lock);
    226 
    227         task_t *receiver = task_get_by_id(receiver_id);
    228         if (receiver == NULL) {
    229                 rc = ENOENT;
    230                 goto finish;
    231         }
    232         if (receiver->sess == NULL) {
    233                 rc = ENOENT;
    234                 goto finish;
    235         }
    236 
    237         /*
    238          * Answer caller first, so that they are not unnecessarily waiting
    239          * while we dump events.
    240          */
    241         async_answer_0(iid, rc);
    242         task_foreach(&dump_walker, receiver->sess);
    243 
    244 finish:
    245         fibril_rwlock_read_unlock(&task_hash_table_lock);
    246229        if (rc != EOK) {
    247230                async_answer_0(iid, rc);
  • uspace/srv/taskman/event.h

    rbb57a00 r4ff66ae  
    4141extern int event_init(void);
    4242
    43 extern int event_register_listener(task_id_t, async_sess_t *);
     43extern void event_register_listener(task_id_t, bool, async_sess_t *,
     44    ipc_callid_t);
    4445extern void dump_events(task_id_t, ipc_callid_t);
    4546extern void wait_for_task(task_id_t, int, ipc_callid_t, task_id_t);
  • uspace/srv/taskman/main.c

    rbb57a00 r4ff66ae  
    186186        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
    187187
     188        bool past_events = IPC_GET_ARG1(*icall);
     189
    188190        /* Atomic -- will be used for notifications only */
    189191        async_sess_t *sess = async_callback_receive(EXCHANGE_ATOMIC);
     
    193195        }
    194196
    195         int rc = event_register_listener(icall->in_task_id, sess);
    196         async_answer_0(iid, rc);
    197 }
    198 
    199 static void taskman_ctl_dump_events(ipc_callid_t iid, ipc_call_t *icall)
    200 {
    201         DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
    202 
    203         dump_events(icall->in_task_id, iid);
     197        event_register_listener(icall->in_task_id, past_events, sess, iid);
    204198}
    205199
     
    263257                taskman_ctl_ev_callback(iid, icall);
    264258                break;
    265         case TASKMAN_DUMP_EVENTS:
    266                 taskman_ctl_dump_events(iid, icall);
    267                 break;
    268259        default:
    269260                return false;
     
    274265static bool handle_implicit_call(ipc_callid_t iid, ipc_call_t *icall)
    275266{
    276         DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__,
     267        /*DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__,
    277268            IPC_GET_IMETHOD(*icall),
    278269            IPC_GET_ARG1(*icall),
    279             icall->in_task_id);
     270            icall->in_task_id);*/
    280271
    281272        if (IPC_GET_IMETHOD(*icall) < IPC_FIRST_USER_METHOD) {
Note: See TracChangeset for help on using the changeset viewer.