void *SB_Thread::Thread::disp(void *pp_arg) { const char *WHERE = "Thread::start(via)"; char la_name[100]; void *lp_fun; void *lp_ret; lp_fun = SB_CB_TO_PTR(iv_fun); if (gv_sb_trace_thread) { la_name[sizeof(la_name) - 1] = '\0'; strncpy(la_name, ip_name, sizeof(la_name) - 1); trace_where_printf(WHERE, "thread started name=%s, fun=%p, arg=%p\n", la_name, lp_fun, pp_arg); } SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_THREAD_START_DISP1, gettid(), reinterpret_cast<SB_Utrace_API_Info_Type>(lp_fun)); lp_ret = iv_fun(pp_arg); SB_UTRACE_API_ADD3(SB_UTRACE_API_OP_THREAD_EXIT_DISP1, gettid(), reinterpret_cast<SB_Utrace_API_Info_Type>(lp_fun)); if (gv_sb_trace_thread) trace_where_printf(WHERE, "thread exiting name=%s, fun=%p, arg=%p, ret=%p\n", la_name, lp_fun, pp_arg, lp_ret); return lp_ret; }
// // Purpose: register event // SB_Export int proc_event_register(short pv_event) { const char *WHERE = "proc_event_register"; short lv_fserr; SB_API_CTR (lv_zctr, PROC_EVENT_REGISTER); if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER event=0x%x\n", pv_event); switch (pv_event) { case LREQ: lv_fserr = XZFIL_ERR_OK; break; case LDONE: lv_fserr = XZFIL_ERR_OK; break; default: lv_fserr = XZFIL_ERR_INVALOP; } if (lv_fserr == XZFIL_ERR_OK) if (!gv_ms_event_mgr.get_mgr(NULL)->register_event(pv_event)) lv_fserr = XZFIL_ERR_TOOMANY; if (gv_ms_trace_params) trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr); return ms_err_rtn(lv_fserr); }
void Pctl_Ext_Wakeup_Thread::run() { const char *WHERE = "Pctl_Ext_Wakeup_Thread::run"; int lv_err; siginfo_t lv_info; sigset_t lv_set; sigemptyset(&lv_set); sigaddset(&lv_set, cv_sig); while (!cv_shutdown) { lv_err = sigwaitinfo(&lv_set, &lv_info); if (gv_ms_trace_params) trace_where_printf(WHERE, "sigwait returned err=%d, sig=%d, val=%d\n", lv_err, lv_info.si_signo, lv_info.si_int); if ((lv_err == -1) && (errno == EINTR)) continue; SB_util_assert_ieq(lv_err, cv_sig); if (lv_info.si_int) { gv_ms_event_mgr.set_event_all(static_cast<short>(lv_info.si_int)); continue; } if (cv_shutdown) break; } if (gv_ms_trace_params) trace_where_printf(WHERE, "EXITING ext wakeup thread\n"); }
// // Purpose: thread-local event manager set event (all) // void SB_Ms_Tl_Event_Mgr::set_event_all(int pv_event) { const char *WHERE = "SB_Ms_Event_Mgr::set_event_all"; int lv_status; SB_Ms_Event_Mgr::Map_All_Entry_Type *lp_all_list_entry; lv_status = SB_Ms_Event_Mgr::cv_sl_map.lock(); SB_util_assert_ieq(lv_status, 0); lp_all_list_entry = reinterpret_cast<SB_Ms_Event_Mgr::Map_All_Entry_Type *> (SB_Ms_Event_Mgr::cv_all_list.head()); if (gv_ms_trace_events && (lp_all_list_entry == NULL)) trace_where_printf(WHERE, "all=EMPTY\n"); while (lp_all_list_entry != NULL) { if (gv_ms_trace_events) trace_where_printf(WHERE, "id=%ld, mgr=%p\n", lp_all_list_entry->iv_link.iv_id.l, pfp(lp_all_list_entry->ip_mgr)); lp_all_list_entry->ip_mgr->set_event(pv_event, NULL); lp_all_list_entry = reinterpret_cast<SB_Ms_Event_Mgr::Map_All_Entry_Type *> (lp_all_list_entry->iv_link.ip_next); } lv_status = SB_Ms_Event_Mgr::cv_sl_map.unlock(); SB_util_assert_ieq(lv_status, 0); }
void SB_Timer::Timer::check_timers() { const char *WHERE = "Timer::check_timers"; char la_fmt_pop[100]; Timer *lp_curr; Timer *lp_next; Time_Stamp lv_now; Slot_Type lv_now_slot; Slot_Type lv_slot; int lv_status; lp_next = NULL; lv_now_slot = hash(lv_now); lv_status = cv_mutex.lock(); SB_util_assert_ieq(lv_status, 0); // sw fault for (lv_slot = cv_last_slot_checked; lv_slot != (lv_now_slot + 1) % MAX_SLOTS; lv_slot = (lv_slot + 1) % MAX_SLOTS) { lp_curr = ca_slots[lv_slot]; while (lp_curr != NULL) { // // we're done if the timer pops later than now. // if (lp_curr->iv_pop_time.ts_gt(lv_now)) { lv_status = cv_mutex.unlock(); SB_util_assert_ieq(lv_status, 0); // sw fault if (cv_trace_enabled) trace_where_printf(WHERE, "no timers ready\n"); return; } lp_next = lp_curr->ip_next; lp_curr->cancel_int(false); if (cv_trace_enabled) trace_where_printf(WHERE, "timer=%p, user-param=%ld, pop time=%s\n", pfp(lp_curr), lp_curr->iv_user_param, lp_curr->format_pop_time(la_fmt_pop)); lp_curr->ip_th->handle_timeout(lp_curr); lp_curr = lp_next; } if (lv_slot != lv_now_slot) { // Only increment if not at "now". A new timer might be // set in the current time slot before "now" goes to the next // slot so we want to be sure and check it again. cv_last_slot_checked = (cv_last_slot_checked + 1) % MAX_SLOTS; } } lv_status = cv_mutex.unlock(); SB_util_assert_ieq(lv_status, 0); // sw fault }
SB_Timer::Tics SB_Timer::Timer::get_wait_time() { const char *WHERE = "Timer::get_wait_time"; Timer *lp_curr; static bool lv_1st_time = true; Slot_Type lv_default_slot; Tics lv_result; Slot_Type lv_slot; int lv_status; if (lv_1st_time) { lv_1st_time = false; lv_result = Time_Stamp::TICS_PER_SEC; if (cv_trace_enabled) trace_where_printf(WHERE, "result=" PF64 "\n", lv_result); return lv_result; } lv_status = cv_mutex.lock(); SB_util_assert_ieq(lv_status, 0); // sw fault lv_result = DEFAULT_WAIT_TICS; lv_default_slot = (cv_last_slot_checked + DEFAULT_SLOT_COUNT) % MAX_SLOTS; // // check for any timers ready to pop between the last slot checked // and the slot of the default wake time. // for (lv_slot = cv_last_slot_checked; lv_slot != lv_default_slot; lv_slot = (lv_slot + 1) % MAX_SLOTS) { lp_curr = ca_slots[lv_slot]; if (lp_curr != NULL) { Time_Stamp lv_now; lv_result = lp_curr->iv_pop_time.ts_sub(lv_now); if (lv_result < 0) lv_result = 0; if (cv_trace_enabled) trace_where_printf(WHERE, "result=" PF64 "\n", lv_result); lv_status = cv_mutex.unlock(); SB_util_assert_ieq(lv_status, 0); // sw fault return lv_result; } } if (cv_trace_enabled) trace_where_printf(WHERE, "result=" PF64 " (default)\n", lv_result); lv_status = cv_mutex.unlock(); SB_util_assert_ieq(lv_status, 0); // sw fault return lv_result; }
// // Purpose: allow external wakeups // SB_Export void proc_enable_external_wakeups() { const char *WHERE = "proc_enable_external_wakeups"; SB_API_CTR (lv_zctr, PROC_ENABLE_EXTERNAL_WAKEUPS); if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER\n"); if (!gv_pctl_external_wakeups) Pctl_Ext_Wakeup_Thread::create(); gv_pctl_external_wakeups = true; if (gv_ms_trace_params) trace_where_printf(WHERE, "EXIT\n"); }
// // Purpose: trace msg and return an ms error // short ms_err_rtn_msg_noassert(const char *pp_where, const char *pp_msg, short pv_fserr) { if (pv_fserr != XZFIL_ERR_OK) { if (gv_ms_trace_errors) trace_where_printf(pp_where, "setting ms (%s) ret=%d\n", pp_msg, pv_fserr); } if (gv_ms_trace_params) trace_where_printf(pp_where, "%s\n", pp_msg); return ms_err_rtn_noassert(pv_fserr); }
// // Purpose: register tid // SB_Export int timer_register() { const char *WHERE = "timer_register"; short lv_fserr; SB_API_CTR (lv_zctr, TIMER_REGISTER); lv_fserr = XZFIL_ERR_OK; if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER\n"); sb_timer_comp_q_get(); gv_ms_event_mgr.get_mgr(NULL); if (gv_ms_trace_params) trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr); return ms_err_rtn(lv_fserr); }
// // wait for TIMER_SIG and process timer-list // void SB_Timer_Thread::run() { const char *WHERE = "SB_Timer_Thread::run"; int lv_err; int lv_sig; sigset_t lv_set; int lv_status; if (gv_ms_trace_timer) trace_where_printf(WHERE, "timer sig thread started\n"); iv_running = true; iv_cv.signal(true); // need lock sigemptyset(&lv_set); sigaddset(&lv_set, TIMER_SIG); while (!iv_shutdown) { lv_err = sigwait(&lv_set, &lv_sig); SB_util_assert_ieq(lv_err, 0); if (gv_ms_trace_timer) trace_where_printf(WHERE, "sigwait returned sig=%d\n", lv_sig); if (iv_shutdown) break; if (lv_sig != TIMER_SIG) continue; lv_status = gv_timer_mutex.lock(); SB_util_assert_ieq(lv_status, 0); sb_timer_timer_list_complete(WHERE); if (gp_timer_head != NULL) { if (gv_ms_trace_timer) sb_timer_timer_list_print(); for (;;) { if (gp_timer_head == NULL) break; // restart timer if (sb_timer_setitimer(WHERE, gp_timer_head->iv_to)) break; sb_timer_timer_list_complete(WHERE); } } lv_status = gv_timer_mutex.unlock(); SB_util_assert_ieq(lv_status, 0); } if (gv_ms_trace_timer) trace_where_printf(WHERE, "EXITING timer sig thread\n"); iv_running = false; }
// // timer-module shutdown // void sb_timer_shutdown() { const char *WHERE = "sb_timer_shutdown"; enum { MAX_TIMER_NODES = 10 }; long la_node[MAX_TIMER_NODES]; void *lp_result; int lv_inx; int lv_max; if (gv_ms_trace_params || gv_ms_trace_timer) trace_where_printf(WHERE, "ENTER\n"); if (gp_timer_thr != NULL) { gp_timer_thr->shutdown(); gp_timer_thr->join(&lp_result); SB_util_assert_peq(lp_result, NULL); // sw fault delete gp_timer_thr; gp_timer_thr = NULL; } delete [] gp_timer_tles; // remove while (gv_timer_tpop_map.size()) { SB_Lmap_Enum *lp_enum = gv_timer_tpop_map.keys(); for (lv_max = 0; lp_enum->more() && (lv_max < MAX_TIMER_NODES); lv_max++) la_node[lv_max] = lp_enum->next()->iv_id.l; for (lv_inx = 0; lv_inx < lv_max; lv_inx++) { Timer_TQ_Node *lp_node = static_cast<Timer_TQ_Node *>(gv_timer_tpop_map.remove(la_node[lv_inx])); delete lp_node; } delete lp_enum; } while (gv_timer_tpop_tid_map.size()) { SB_Lmap_Enum *lp_enum = gv_timer_tpop_tid_map.keys(); for (lv_max = 0; lp_enum->more() && (lv_max < MAX_TIMER_NODES); lv_max++) la_node[lv_max] = lp_enum->next()->iv_id.l; for (lv_inx = 0; lv_inx < lv_max; lv_inx++) { Timer_TQ_Node *lp_node = static_cast<Timer_TQ_Node *>(gv_timer_tpop_tid_map.remove(la_node[lv_inx])); delete lp_node; } delete lp_enum; } if (gv_ms_trace_params || gv_ms_trace_timer) trace_where_printf(WHERE, "EXIT\n"); }
// // Purpose: trace msg and return an ms error // short ms_err_rtn_msg(const char *pp_where, const char *pp_msg, short pv_fserr) { if (pv_fserr != XZFIL_ERR_OK) { SB_UTRACE_API_ADD2(SB_UTRACE_API_OP_MS_EXIT, pv_fserr); if (gv_ms_trace_errors) trace_where_printf(pp_where, "setting ms (%s) ret=%d\n", pp_msg, pv_fserr); if (gv_ms_assert_error) SB_util_assert_ieq(pv_fserr, XZFIL_ERR_OK); // sw fault } if (gv_ms_trace_params) trace_where_printf(pp_where, "%s\n", pp_msg); return ms_err_rtn(pv_fserr); }
// // Purpose: thread-local event manager set event (registered) // void SB_Ms_Tl_Event_Mgr::set_event_reg(int pv_event, bool *pp_done) { const char *WHERE = "SB_Ms_Event_Mgr::set_event_reg"; int lv_status; int lv_event; switch (pv_event) { case LREQ: lv_event = SB_Ms_Event_Mgr::EVENT_LREQ; break; case LDONE: lv_event = SB_Ms_Event_Mgr::EVENT_LDONE; break; default: lv_event = -1; // touch SB_util_abort("invalid pv_event"); // sw fault } lv_status = SB_Ms_Event_Mgr::cv_sl_map.lock(); SB_util_assert_ieq(lv_status, 0); SB_Lmap_Enum lv_enum(&SB_Ms_Event_Mgr::ca_reg_map[lv_event]); while (lv_enum.more()) { SB_Ms_Event_Mgr::Map_Reg_Entry_Type *lp_reg_entry = reinterpret_cast<SB_Ms_Event_Mgr::Map_Reg_Entry_Type *>(lv_enum.next()); if (gv_ms_trace_events) trace_where_printf(WHERE, "id=%ld, mgr=%p\n", lp_reg_entry->iv_link.iv_id.l, pfp(lp_reg_entry->ip_mgr)); lp_reg_entry->ip_mgr->set_event(pv_event, pp_done); } lv_status = SB_Ms_Event_Mgr::cv_sl_map.unlock(); SB_util_assert_ieq(lv_status, 0); }
// // Purpose: event manager - register group/pin // void SB_Ms_Event_Mgr::register_group_pin(int pv_group, int pv_pin) { const char *WHERE = "SB_Ms_Event_Mgr::register_group_pin"; if (gv_ms_trace_events) trace_where_printf(WHERE, "id=%ld, mgr=%p, group=%d, pin=%d\n", iv_id, pfp(this), pv_group, pv_pin); iv_group = pv_group; iv_pin = pv_pin; if (pv_group >= 0) { cv_group_map.lock(); Map_Group_Entry_Type *lp_group_entry = static_cast<Map_Group_Entry_Type *>(cv_group_map.get_lock(pv_group, false)); if (lp_group_entry == NULL) { iv_group_entry.iv_link.iv_id.i = pv_group; iv_group_entry.ip_map = new SB_Imap(); cv_group_map.put_lock(&iv_group_entry.iv_link, false); lp_group_entry = &iv_group_entry; } cv_group_map.unlock(); iv_group_pin_entry.iv_link.iv_id.i = pv_pin; iv_group_pin_entry.ip_mgr = this; lp_group_entry->ip_map->put(&iv_group_pin_entry.iv_link); } iv_pin_entry.iv_link.iv_id.i = pv_pin; iv_pin_entry.iv_group = pv_group; iv_pin_entry.ip_mgr = this; cv_pin_map.put(&iv_pin_entry.iv_link); }
// // Purpose: event manager - register event // bool SB_Ms_Event_Mgr::register_event(int pv_event) { const char *WHERE = "SB_Ms_Event_Mgr::register_event"; int lv_status; if (gv_ms_trace_events) trace_where_printf(WHERE, "event=0x%x\n", pv_event); int lv_event; switch (pv_event) { case LREQ: lv_event = EVENT_LREQ; break; case LDONE: lv_event = EVENT_LDONE; break; default: lv_event = -1; // touch SB_util_abort("invalid pv_event"); // sw fault } long lv_id = SB_Thread::Sthr::self_id(); Map_Reg_Entry_Type *lp_reg_entry = static_cast<Map_Reg_Entry_Type *>(ca_reg_map[lv_event].get(lv_id)); if (lp_reg_entry == NULL) { ia_reg_entry[lv_event].iv_link.iv_id.l = lv_id; ia_reg_entry[lv_event].ip_mgr = this; lv_status = cv_sl_map.lock(); SB_util_assert_ieq(lv_status, 0); ca_reg_map[lv_event].put(reinterpret_cast<SB_LML_Type *>(&ia_reg_entry[lv_event].iv_link)); lv_status = cv_sl_map.unlock(); SB_util_assert_ieq(lv_status, 0); return true; } else return false; }
SB_Timer::Timer::Timer(TH *pp_th, long pv_user_param, Tics pv_interval, bool pv_start) { const char *WHERE = "Timer::Timer"; SB_util_assert_pne(pp_th, NULL); ip_th = pp_th; iv_user_param = pv_user_param; if (pv_interval > ((MAX_SLOTS-1) * TICS_PER_SLOT)) // Don't allow interval that would cause a wrap-around of // the timer slots array. pv_interval = (MAX_SLOTS-1) * TICS_PER_SLOT; else if (pv_interval < 0) pv_interval = 0; iv_interval = pv_interval; ip_next = NULL; iv_running = false; if (cv_trace_enabled) trace_where_printf(WHERE, "timer=%p, user-param=%ld, interval=" PF64 ", start=%d\n", pfp(this), iv_user_param, iv_interval, pv_start); if (pv_start) start(); }
void SB_Lf_Queue::add(SB_QL_Type *pp_item) { #ifdef SB_Q_ALLOW_QALLOC const char *WHERE = "SB_Lf_Queue::add"; #endif LFNT *lp_node; PT lv_next; PT lv_tail; PT lv_temp; lp_node = new LFNT; #ifdef SB_Q_ALLOW_QALLOC if (gv_ms_trace_qalloc) trace_where_printf(WHERE, "this=%p(%s), new=%p\n", pfp(this), ia_q_name, pfp(lp_node)); #endif LFQ_PT_AS3(&lp_node->iv_next, NULL, 0); lp_node->ip_data = pp_item; for (;;) { // Keep trying until Enqueue is done LFQ_PT_AS2(&lv_tail, &iv_tail); // Read Tail.ptr and Tail.count together LFQ_PT_AS2(&lv_next, lv_tail.ip_ptr); // Read next ptr and count fields together if (lv_tail == iv_tail) { // Are tail and next consistent? if (lv_next.ip_ptr == NULL) { // Was Tail pointing to the last node? LFQ_PT_AS3(&lv_temp, &lp_node->iv_next, lv_next.iv_count + 1); if (LFQ_CAS(lv_tail.ip_ptr, lv_next, lv_temp)) { // Try to link node at the end of the linked list break; // Enqueue is done. Exit loop } } else { // Tail was not pointing to the last node LFQ_PT_AS3(&lv_temp, lv_next.ip_ptr, lv_tail.iv_count + 1); LFQ_CAS(&iv_tail, lv_tail, lv_temp); // Try to swing Tail to the next node } } } LFQ_PT_AS3(&lv_temp, &lp_node->iv_next, lv_tail.iv_count + 1); LFQ_CAS(&iv_tail, lv_tail, lv_temp); // Enqueue is done. Try to swing Tail to the inserted node }
// // Purpose: A near close to XSIGNALTIMEOUT, but callback is called on to // SB_Export int timer_start_cb(int pv_toval, short pv_parm1, long pv_parm2, short *pp_tleid, Timer_Cb_Type pv_callback) { const char *WHERE = "timer_start_cb"; void *lp_cb; short lv_fserr; SB_API_CTR (lv_zctr, TIMER_START_CB); if (gv_ms_trace_params) { lp_cb = SB_CB_TO_PTR(pv_callback); trace_where_printf(WHERE, "ENTER toval=%d, parm1=%d(0x%x), parm2=%ld(0x%lx), tleid=%p, cb=%p\n", pv_toval, pv_parm1, pv_parm1, pv_parm2, pv_parm2, pfp(pp_tleid), lp_cb); } lv_fserr = sb_timer_start_com(WHERE, false, TIMER_TLE_KIND_CB, pv_toval, pv_parm1, pv_parm2, pp_tleid, 0, NULL, pv_callback); return ms_err_rtn(lv_fserr); }
// // Purpose: destructor event-manager // SB_Ms_Event_Mgr::~SB_Ms_Event_Mgr() { const char *WHERE = "SB_Ms_Event_Mgr::~SB_Ms_Event_Mgr"; int lv_status; if (gv_ms_trace_events) trace_where_printf(WHERE, "ENTER id=%ld, mgr=%p\n", iv_id, pfp(this)); if (!iv_mutex_locked) { lv_status = cv_sl_map.lock(); SB_util_assert_ieq(lv_status, 0); } cv_all_list.remove_list(&iv_all_list_entry.iv_link); cv_all_map.remove(iv_all_map_entry.iv_link.iv_id.l); if (!iv_mutex_locked) { lv_status = cv_sl_map.unlock(); SB_util_assert_ieq(lv_status, 0); } for (int lv_event = 0; lv_event < EVENT_MAX; lv_event++) ca_reg_map[lv_event].remove(ia_reg_entry[lv_event].iv_link.iv_id.l); if (iv_pin >= 0) { Map_Pin_Entry_Type *lp_entry = static_cast<Map_Pin_Entry_Type *>(cv_pin_map.remove(iv_pin)); SB_util_assert_peq(lp_entry, &iv_pin_entry); // sw fault lp_entry = lp_entry; // touch (in case assert disabled) if (gv_ms_trace_events) trace_where_printf(WHERE, "id=%ld, mgr=%p, deleting pin=%d\n", iv_id, pfp(this), iv_pin); } if (iv_group_entry.ip_map != NULL) delete iv_group_entry.ip_map; // Clear TLS if (iv_tls_inx >= 0) { lv_status = SB_Thread::Sthr::specific_set(iv_tls_inx, NULL); SB_util_assert_ieq(lv_status, 0); } // destroy CV do { lv_status = iv_cv.destroy(); if (lv_status == EBUSY) usleep(100); } while (lv_status); if (gv_ms_trace_events) trace_where_printf(WHERE, "EXIT id=%ld, mgr=%p\n", iv_id, pfp(this)); }
void SB_Timer::Timer::start() { const char *WHERE = "Timer::start"; char la_fmt_pop[100]; Timer *lp_curr; Timer *lp_next; const char *lp_trace_type; Slot_Type lv_slot; int lv_status; if (iv_running) { lp_trace_type = "(re)start"; cancel_int(true); } else lp_trace_type = "start"; iv_pop_time.tic_set_now_add(iv_interval); lv_slot = hash(iv_pop_time); if (cv_trace_enabled) trace_where_printf(WHERE, "%s, timer=%p, user-param=%ld, interval=" PF64 ", pop time=%s, slot=%d\n", lp_trace_type, pfp(this), iv_user_param, iv_interval, format_pop_time(la_fmt_pop), lv_slot); lv_status = cv_mutex.lock(); SB_util_assert_ieq(lv_status, 0); // sw fault lp_curr = ca_slots[lv_slot]; // is it the only one in this slot? if (lp_curr == NULL) { ca_slots[lv_slot] = this; ip_next = NULL; } else if (iv_pop_time.ts_lt(lp_curr->iv_pop_time)) { // should it go first in this slot? ca_slots[lv_slot] = this; ip_next = lp_curr; } else { // it goes somewhere after the first lp_next = lp_curr->ip_next; while ((lp_next != NULL) && (iv_pop_time.ts_ge(lp_next->iv_pop_time))) { lp_curr = lp_next; lp_next = lp_curr->ip_next; } lp_curr->ip_next = this; ip_next = lp_next; } iv_running = true; lv_status = cv_mutex.unlock(); SB_util_assert_ieq(lv_status, 0); // sw fault }
SB_Export short XPROCESSHANDLE_NULLIT_(SB_Phandle_Type *pp_phandle) { const char *WHERE = "XPROCESSHANDLE_NULLIT_"; SB_API_CTR (lv_zctr, XPROCESSHANDLE_NULLIT_); if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER phandle=%p\n", pfp(pp_phandle)); if (!gv_ms_calls_ok) return ms_err_rtn_msg(WHERE, "msg_init() not called or shutdown", XZFIL_ERR_INVALIDSTATE); if (pp_phandle == NULL) return ms_err_rtn_msg(WHERE, "invalid phandle", XZFIL_ERR_BOUNDSERR); for (int lv_inx = 0; lv_inx < SB_PHANDLE_LL_SIZE; lv_inx++) pp_phandle->_data[lv_inx] = -1; if (gv_ms_trace_params) trace_where_printf(WHERE, "EXIT OK\n"); return XZFIL_ERR_OK; }
// // Purpose: emulate SIGNALTIMEOUT // SB_Export _xcc_status XSIGNALTIMEOUT(int pv_toval, short pv_parm1, long pv_parm2, short *pp_tleid, pid_t pv_tid) { const char *WHERE = "XSIGNALTIMEOUT"; SB_Ms_Event_Mgr *lp_mgr; int lv_fserr; short lv_tleid; SB_API_CTR (lv_zctr, XSIGNALTIMEOUT); if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER toval=%d, parm1=%d(0x%x), parm2=%ld(0x%lx), tleid=%p, ttid=%d\n", pv_toval, pv_parm1, pv_parm1, pv_parm2, pv_parm2, pfp(pp_tleid), pv_tid); if (pv_tid == 0) lp_mgr = gv_ms_event_mgr.get_mgr(NULL); else { lp_mgr = gv_ms_event_mgr.get_mgr_tid(pv_tid); if (lp_mgr == NULL) { if (gv_ms_trace_params) trace_where_printf(WHERE, "ttid=%d not registered\n", pv_tid); lv_fserr = XZFIL_ERR_BADERR; // CCL lv_tleid = -1; *pp_tleid = lv_tleid; if (gv_ms_trace_params) trace_where_printf(WHERE, "EXIT tleid=%d, ret=%d\n", lv_tleid, lv_fserr); RETURNFSCC(lv_fserr); } } lv_fserr = sb_timer_start_com(WHERE, true, TIMER_TLE_KIND_COMPQ, pv_toval, pv_parm1, pv_parm2, pp_tleid, pv_tid, lp_mgr, NULL); RETURNFSCC(lv_fserr); }
SB_Export short XPROCESSHANDLE_GETMINE_(SB_Phandle_Type *pp_phandle) { const char *WHERE = "XPROCESSHANDLE_GETMINE_"; SB_API_CTR (lv_zctr, XPROCESSHANDLE_GETMINE_); if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER phandle=%p\n", pfp(pp_phandle)); if (!gv_ms_calls_ok) return ms_err_rtn_msg(WHERE, "msg_init() not called or shutdown", XZFIL_ERR_INVALIDSTATE); ms_od_get_my_phandle(pp_phandle); if (gv_ms_trace_params) { char la_phandle[MSG_UTIL_PHANDLE_LEN]; msg_util_format_phandle(la_phandle, pp_phandle); trace_where_printf(WHERE, "EXIT OK, phandle=%s\n", la_phandle); } return XZFIL_ERR_OK; }
void SB_Timer::Timer::set_param(long pv_user_param) { const char *WHERE = "Timer::set_param"; if (cv_trace_enabled) trace_where_printf(WHERE, "timer=%p, user-param=%ld\n", pfp(this), pv_user_param); iv_user_param = pv_user_param; }
// // free TLE // void sb_timer_tle_free(Timer_TLE_Type *pp_tle) { const char *WHERE = "sb_timer_tle_free"; int lv_tleid; lv_tleid = pp_tle->iv_tleid; pp_tle->iv_inuse = false; gp_timer_tle_mgr->free_slot(lv_tleid); if (gv_ms_trace_timer) trace_where_printf(WHERE, "free tleid=%d\n", lv_tleid); }
void sb_timer_setitimer_retry(const char *pp_where, SB_To pv_to) { while (!sb_timer_setitimer(pp_where, pv_to)) { // itimer not set - timer already expired if (gv_ms_trace_timer) trace_where_printf(pp_where, "setitimer not set - try to complete timers\n"); sb_timer_timer_list_complete(pp_where); if (gp_timer_head == NULL) break; } }
SB_Export int proc_set_process_completion() { const char *WHERE = "proc_set_process_completion"; int lv_fserr; SB_API_CTR (lv_zctr, PROC_SET_PROCESS_COMPLETION); if (gv_ms_trace_params) trace_where_printf(WHERE, "ENTER\n"); if (!gv_ms_calls_ok) return ms_err_rtn_msg(WHERE, "msg_init() not called or shutdown", XZFIL_ERR_INVALIDSTATE); gv_ms_process_comp = true; #ifndef USE_EVENT_REG gv_ms_event_mgr.set_ret_gmgr(true); #endif lv_fserr = XZFIL_ERR_OK; if (gv_ms_trace_params) trace_where_printf(WHERE, "EXIT ret=%d\n", lv_fserr); return ms_err_rtn(static_cast<short>(lv_fserr)); }
// // Purpose: event manager - register tls destructor // void SB_Ms_Event_Mgr::register_tls_dtor(int pv_inx, void (*pp_dtor)(void *pp_data), void *pp_data) { const char *WHERE = "SB_Ms_Event_Mgr::register_tls_dtor"; SB_util_assert_peq(ia_tls_dtor[pv_inx].ip_dtor, NULL); ia_tls_dtor[pv_inx].iv_dtor = pp_dtor; ia_tls_dtor_data[pv_inx] = pp_data; if (gv_ms_trace_events) trace_where_printf(WHERE, "inx=%d, data=%p\n", pv_inx, pp_data); }
SB_Timer::Timer::~Timer() { const char *WHERE = "Timer::~Timer"; cancel_int(true); if (cv_trace_enabled) trace_where_printf(WHERE, "timer=%p, user-param=%ld, interval=" PF64 "\n", pfp(this), iv_user_param, iv_interval); }
// // Purpose: like ms_err_rtn_msg, but the error is fatal // short ms_err_rtn_msg_fatal(const char *pp_where, const char *pp_msg, short pv_fserr, bool pv_stderr) { SB_Buf_Line la_msg; if (gv_ms_trace_errors) trace_where_printf(pp_where, "setting ms (%s) ret=%d\n", pp_msg, pv_fserr); sprintf(la_msg, "%s, fserr=%d", pp_msg, pv_fserr); return ms_err_rtn_fatal(la_msg, pv_fserr, pv_stderr); }