示例#1
0
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;
}
示例#2
0
文件: sysfuncs.c 项目: codyd51/axle
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);
}
示例#3
0
文件: task.c 项目: codyd51/axle
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);
}
示例#4
0
int block_current_task(void)
{
	return block_task(per_core(current_task)->id);
}