static void __attribute__((noinline)) _task_dump_trace_dispatch(int sig) { int need_dispatch = 1; task_id_t running = task_get_running(); if (!pthread_equal(pthread_self(), main_thread)) { need_dispatch = 0; } else if (!task_start_called()) { fprintf(stderr, "Stack trace of main thread:\n"); need_dispatch = 0; } else if (in_interrupt_context()) { fprintf(stderr, "Stack trace of ISR:\n"); } else { fprintf(stderr, "Stack trace of task %d (%s):\n", running, task_get_name(running)); } if (need_dispatch) { pthread_kill(task_get_thread(running), SIGNAL_TRACE_DUMP); } else { _task_dump_trace_impl(SIGNAL_TRACE_OFFSET); exit(1); } }
void task_cond_wait(struct task_cond* cond, struct mutex *mutex) { mutex_unlock(mutex); task_add_to_wait_list(task_get_running(), &cond->wait_list); mutex_lock(mutex); }