forked from xuos/xiuos
Support running task list management.
This commit is contained in:
@@ -40,6 +40,11 @@ int sys_exit(struct TaskMicroDescriptor* ptask)
|
||||
{
|
||||
assert(ptask != NULL);
|
||||
ptask->dead = true;
|
||||
// free that task straightly if it's a blocked task
|
||||
if (ptask->state == BLOCKED) {
|
||||
xizi_task_manager.free_pcb(ptask);
|
||||
}
|
||||
// yield current task in case it wants to exit itself
|
||||
xizi_task_manager.task_yield_noschedule(cur_cpu()->task, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,25 @@ extern int sys_exit(struct TaskMicroDescriptor* task);
|
||||
int sys_kill(int id)
|
||||
{
|
||||
struct TaskMicroDescriptor* task = NULL;
|
||||
// check if task is a running one
|
||||
DOUBLE_LIST_FOR_EACH_ENTRY(task, &xizi_task_manager.task_running_list_head, node)
|
||||
{
|
||||
if (task->pid == id) {
|
||||
sys_exit(task);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// check if task is a blocking one
|
||||
DOUBLE_LIST_FOR_EACH_ENTRY(task, &xizi_task_manager.task_blocked_list_head, node)
|
||||
{
|
||||
if (task->pid == id) {
|
||||
sys_exit(task);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// check if task is a ready one
|
||||
for (int prio = 0; prio < TASK_MAX_PRIORITY; prio++) {
|
||||
DOUBLE_LIST_FOR_EACH_ENTRY(task, &xizi_task_manager.task_list_head[prio], node)
|
||||
{
|
||||
|
||||
@@ -140,8 +140,6 @@ int sys_unbind_irq(struct TaskMicroDescriptor* task, int irq_num)
|
||||
}
|
||||
|
||||
irq_forward_table[irq_num].handle_task = NULL;
|
||||
sys_close_session(kernel_irq_proxy, &irq_forward_table[irq_num].session);
|
||||
DEBUG("Unbind: %s to irq %d", task->name, irq_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,13 @@ void show_tasks(void)
|
||||
}
|
||||
LOG_PRINTF("******************************************************\n");
|
||||
LOG_PRINTF("STAT ID TASK PRI MEM(KB)\n");
|
||||
DOUBLE_LIST_FOR_EACH_ENTRY(task, &xizi_task_manager.task_running_list_head, node)
|
||||
{
|
||||
LOG_PRINTF("RUNNING ");
|
||||
_padding(task->name);
|
||||
LOG_PRINTF(" %d %s %d %d\n", task->pid, task->name, task->priority, task->mem_size >> 10);
|
||||
}
|
||||
|
||||
for (int i = 0; i < TASK_MAX_PRIORITY; i++) {
|
||||
if (IS_DOUBLE_LIST_EMPTY(&xizi_task_manager.task_list_head[i])) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user