/* Intended to be called from interrupt context only */ void task_trigger_exception (struct task *task, int exception, busword_t textaddr, busword_t data, int code) { DECLARE_CRITICAL_SECTION (except); ASSERT (get_current_context () == KERNEL_CONTEXT_INTERRUPT); ASSERT (get_current_task () == task); if (exception < 0 || exception >= EX_MAX) FAIL ("exception code unrecognized\n"); if (task->ts_ex_handlers[exception] == NULL) { /* Process shall be killed */ TASK_ATOMIC_ENTER (except); (void) wake_up (task, TASK_STATE_EXITED, 0); task_destroy (task); schedule (); TASK_ATOMIC_LEAVE (except); } else (task->ts_ex_handlers[exception]) (task, exception, textaddr, data, code); }
unsigned char TOS_parampost(void (*tp) (), uint32_t arg) { DECLARE_CRITICAL_SECTION(); uint8_t tmp; // dbg(DBG_SCHED, ("TOSH_post: %d 0x%x\n", TOSH_sched_free, (int)tp)); CRITICAL_SECTION_BEGIN(); tmp = TOSH_sched_free; if (TOSH_queue[tmp].tp == 0x0) { #ifdef TASK_QUEUE_DEBUG occupancy++; if (occupancy > max_occupancy) { max_occupancy = occupancy; } #endif if(pushqueue(¶mtaskQueue, arg)){ TOSH_sched_free = (tmp + 1) & sys_task_bitmask; TOSH_queue[tmp].tp = tp; TOSH_queue[tmp].postingFunction = (void *)__builtin_return_address(0); TOSH_queue[tmp].timestamp = OSCR0; TOSH_queue[tmp].executeTime = 0; } else{ printFatalErrorMsg("paramtaskqueue full",0); } CRITICAL_SECTION_END(); return 0x1; } else { #ifdef TASK_QUEUE_DEBUG failed_post++; #endif CRITICAL_SECTION_END(); printFatalErrorMsg("TaskQueue Full. Size = ", 1,sys_max_tasks); return 0x0; } }