int main(int argc, char **argv) { struct task *task; printf("PID USER PR COMMAND\n"); task_foreach(task) { printf("%-3d %-4d % 3d %s\n", tid, task_resource_u_area(task)->reuid, task_get_priority(task), task_get_name(task)); } return 0; }
void task_init(struct task *tsk, int id, struct task *parent, const char *name, struct thread *main_thread, task_priority_t priority) { assert(tsk == task_kernel_task()); assert(id == task_get_id(tsk)); assert(0 == strcmp(name, task_get_name(tsk))); assert(main_thread == task_get_main(tsk)); assert(TASK_PRIORITY_DEFAULT == task_get_priority(tsk)); if (main_thread != NULL) { /* check for thread.NoThreads module */ main_thread->task = tsk; } task_resource_init(tsk); }
int getpriority(int which, id_t who) { struct task *task; int priority; if (!xetpriority_which_ok(which)) { return SET_ERRNO(EINVAL); } priority = INT_MAX; task_foreach(task) { if (xetpriority_match(which, who, task)) { priority = min(priority, task_get_priority(task)); } } return priority != INT_MAX ? priority : SET_ERRNO(ESRCH); }
void task2(char *str) { int i = 0; TCB *tcb; tcb = get_current_task_tcb(); while(1) { printf("T2:%p:%d:%s:%d:%d\n", tcb, i++, str, task_get_priority(tcb), sys_check_stack(tcb)); if(i >= 3) break; //show_run_queue(); yield(); } }
void task1(char *str) { int i = 0; TCB *tcb; tcb = get_current_task_tcb(); while(1) { printf("T1:%p:%d:%s:%d:%d\n", tcb, i++, str, task_get_priority(tcb), sys_check_stack(tcb)); send_msg_sync(print_task_tcb, (void *)"this isa test from 1", 100); if(i >= 2) break; //show_run_queue(); yield(); } }
void task3(char *str) { int i = 0; TCB *tcb; tcb = get_current_task_tcb(); while(1) { printf("T3:%p:%d:%s:%d:%d\n", tcb, i++, str, task_get_priority(tcb), sys_check_stack(tcb)); //raise_signal(NULL, SIGNAL_KILL); if(i >= 7) break; //show_run_queue(); yield(); } }