pt_regs_t *child_regs = ((pt_regs_t *)(TASK_SIZE + (unsigned long)tsk)) - 1;
- printk("child regs: %x %x %d\n", child_regs, regs, sizeof(regs));
- //*child_regs = *regs;
+ printk("child regs: %x %x\n", child_regs, regs);
memcpy(child_regs, regs, sizeof(*regs));
- asm("xchg %bx, %bx");
child_regs->eax = 0;
- //child_regs->eflags |= 0x200; // enable IF
+ child_regs->eflags |= 0x200; // enable IF
tsk->esp0 = TASK_SIZE + (unsigned long)tsk;
tsk->esp = (unsigned long)child_regs;
printk("tsk %08x child_regs esp %08x esp0 %08x\n", tsk, tsk->esp, tsk->esp0);
- tsk->state = TASK_RUNNING;
+ tsk->state = TASK_INITING;
tsk->weight = TASK_INIT_WEIGHT;
INIT_LIST_HEAD(&tsk->list);
- disable_irq();
-
unsigned long iflags;
irq_save(iflags);
list_add(&tsk->list, &all_tasks);
irq_restore(iflags);
+ tsk->state = TASK_RUNNING;
+
printk("%s:%d\n", __func__, __LINE__);
return (int)tsk->pid;
extern void ret_from_fork_krnl();
void kernel_task(char *name, void *entry) {
pt_regs_t regs;
-
+
memset((void *)®s, 0, sizeof(regs));
-
+
// 内核任务入口
regs.edx = (unsigned long)entry;
-
+
// 创建内核任务的时候就直接指定其在fork后走的路径
// 就不用走sysexit那个路径了
regs.eip = (unsigned long)ret_from_fork_krnl;
regs.ds = SELECTOR_KRNL_DS;
regs.es = SELECTOR_KRNL_DS;
regs.ss = SELECTOR_KRNL_DS;
- regs.eflags = (1 << 9); // enable IF
int pid = do_fork(®s, FORK_KRNL);
printk("kernel task pid is %d\n", pid);
-
- enable_irq();
}
void root_task_entry() {