/** * Create a new task * @author Ivan Gualandri * @version 1.0 * @param task_name The name of the task * @param start_function the entry point of the task. */ pid_t new_task(char *task_name, void (*start_function)()){ asm("cli"); task_t *new_task; table_address_t local_table; unsigned int new_pid = request_pid(); new_task = (task_t*)kmalloc(sizeof(task_t)); strcpy(new_task->name, task_name); new_task->next = NULL; new_task->start_function = start_function; new_task->cur_quants=0; new_task->pid = new_pid; new_task->eip = (unsigned int)start_function; new_task->esp = (unsigned int)kmalloc(STACK_SIZE) + STACK_SIZE-100; new_task->tty = tty_get_current(); dbg_bochs_print(new_task->esp); new_task->status = NEW; new_task->registers = (task_register_t*)new_task->esp; new_tss(new_task->registers, start_function); local_table = map_kernel(); new_task->pdir = local_table.page_dir; new_task->ptable = local_table.page_table; //new_task->pdir = 0; //new_task->ptable = 0; enqueue_task(new_task->pid, new_task); //(task_list.current)->cur_quants = MAX_TICKS; asm("sti"); return new_pid; }
/** * Create a new task * @author Ivan Gualandri * @version 1.0 * @param task_name The name of the task * @param start_function the entry point of the task. */ pid_t new_task(char *task_name, void (*start_function)()){ asm("cli"); task_t new_task; table_address_t local_table; unsigned int new_pid = request_pid(); strcpy(new_task.name, task_name); new_task.start_function = start_function; new_task.pid = new_pid; new_task.eip = (unsigned int)start_function; new_task.esp = (unsigned int) kmalloc(STACK_SIZE) + STACK_SIZE - 100; new_task.state = READY; new_task.registers = (task_register_t*)new_task.esp; new_tss(new_task.registers, start_function); local_table = map_kernel(); new_task.pdir = local_table.page_dir; new_task.ptable = local_table.page_table; add_task(new_task.pid, &new_task); asm("sti"); return new_pid; }