int set_timer(uint64_t deadline) { task_t* curr_task; uint32_t core_id; uint8_t flags; int ret = -EINVAL; flags = irq_nested_disable(); curr_task = per_core(current_task); core_id = CORE_ID; if (curr_task->status == TASK_RUNNING) { // blocks task and removes from ready queue block_task(curr_task->id); curr_task->flags |= TASK_TIMER; curr_task->timeout = deadline; timer_queue_push(core_id, curr_task); ret = 0; } else { LOG_INFO("Task is already blocked. No timer will be set!\n"); } irq_nested_enable(flags); return ret; }
void yield(task_state reason) { if (!tasking_is_active()) return; //if a task is yielding not because it's waiting for i/o, but because it willingly gave up cpu, //then it should not be blocked //block_task would manage this itself, but we can skip block_task overhead by doing it here ourselves if (reason == RUNNABLE) { task_switch_now(); return; } panic("not runnable"); extern task_t* current_task; block_task(current_task, reason); }
void kill_task(task_t* task) { Deprecated(); bool show_died_message = !strcmp(task->name, "xserv"); if (show_died_message) { xserv_fail(); } if (is_dead_task_crit(task)) { tasking_critical_fail(); } if (task == first_responder_task) { resign_first_responder(); } block_task(task, ZOMBIE); }
int block_current_task(void) { return block_task(per_core(current_task)->id); }