void task_poll_for_work() { Task* t; while((t = task_get())) { t->task(t->user); release_ref(t, kmem_free); } }
pid_t sys_getpgid(pid_t pid) { if (pid == 0) { pid = CurrentTask->pid; } task_t *task = task_get(pid); if (task == NULL) { errno = ESRCH; return -1; } return task->pid; }
int kcreate_test() { reset(); kcreate(t2, MEDIUM, 0, 0); vassert(t2->state == READY); vassert(task_get_return_value(t2) > t2->tid); Task *child = task_get(task_get_return_value(t2)); vassert(child != 0); vassert(child->state == READY); return 0; }
static void cmd_ps() { BEGIN_CMD(); tcb_t * current, * target; target = task_get(); current = target; do { print(current->tid);ENTER(); current = current->next; } while(current != target); END_CMD(); }
t_status interface_task_attribute_sched(o_syscall* message) { o_task* o; if (task_get(message->u.request.u.task_attribute_sched.arg1, &o) != STATUS_OK) { message->u.reply.error = STATUS_ERROR; } else { message->u.reply.error = STATUS_OK; message->u.reply.u.task_attribute_sched.result1 = o->state; } return (STATUS_OK); }
int sys_setpgid(pid_t pid, pid_t pgid) { if (pid == 0) { pid = CurrentTask->pid; } task_t *task = task_get(pid); if (task == NULL) { errno = ESRCH; return -1; } if (pgid == 0) { pgid = task->pid; } task->pgid = pgid; return 0; }
t_error ia32_thread_reserve(i_task tsk, i_thread* th) { o_thread *oth; ao_thread_named *src; o_task* otsk; o_as* oas; if (thread_get(*th, &oth) != ERROR_NONE) THREAD_LEAVE(thread, ERROR_UNKNOWN); src = &(oth->machdep.named); if (task_get(oth->taskid, &otsk) != ERROR_NONE) TASK_LEAVE(task, ERROR_UNKNOWN); if (as_get(otsk->asid, &oas) != ERROR_NONE) AS_LEAVE(as, ERROR_UNKNOWN); src->cr3 = (t_uint32) oas->machdep.pd; return ERROR_NONE; }
int task_is_invalid(tid_t tid) { Task *task = task_get(tid); if (task == 0) return -1; else if (task->state == ZOMBIE) return -2; else return 0; }
void architecture_handler_spurious(t_uint32 n) { i_thread id; o_thread* thread; o_task* task; t_uint32 stack[8]; as_context ctx; /* * 2) */ assert(thread_current(&id) == STATUS_OK); /* * 3) */ assert(architecture_context_get(id, &ctx) == STATUS_OK); /* * 4) */ module_call(console, message, '!', "spurious: n(%u) thread(%qu)\n", n, id); module_call(console, message, '!', " eip(0x%08x) ebp(0x%08x) esp(0x%08x) eflags(0x%08x)\n", ctx.eip, ctx.ebp, ctx.esp, ctx.eflags); module_call(console, message, '!', " cs(0x%x) ds(0x%x) ss(0x%x)\n", ctx.cs, ctx.ds, ctx.ss); module_call(console, message, '!', " eax(0x%x) ebx(0x%x) ecx(0x%x) edx(0x%x) " "esi(0x%x) edi(0x%x)\n", ctx.eax, ctx.ebx, ctx.ecx, ctx.edx, ctx.esi, ctx.edi); /* * 5) */ assert(thread_get(id, &thread) == STATUS_OK); assert(task_get(thread->task, &task) == STATUS_OK); /* * 6) */ assert(as_read(task->as, ctx.esp, sizeof (stack), stack) == STATUS_OK); /* * 7) */ module_call(console, message, '!', " stack: \n" " 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", stack[0], stack[1], stack[2], stack[3], stack[4], stack[5], stack[6], stack[7]); }