X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/bffa3430fbbaaad29bec0b5bee9c1f0bfc7fd068..refs/heads/cor/lrud:/lunaix-os/kernel/process/sched.c diff --git a/lunaix-os/kernel/process/sched.c b/lunaix-os/kernel/process/sched.c index 945fc01..ccf0e45 100644 --- a/lunaix-os/kernel/process/sched.c +++ b/lunaix-os/kernel/process/sched.c @@ -1,7 +1,7 @@ -#include -#include +#include +#include -#include +#include #include #include @@ -20,13 +20,11 @@ #include #include -#include - #include struct thread empty_thread_obj; -volatile struct proc_info* __current; +volatile struct proc_info* __current = NULL; volatile struct thread* current_thread = &empty_thread_obj; struct scheduler sched_ctx; @@ -221,39 +219,11 @@ schedule() sched_ctx.procs_index = to_check->process->pid; done: - isrm_notify_eos(0); run(to_check); fail("unexpected return from scheduler"); } -__DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds) -{ - if (!seconds) { - return 0; - } - - time_t systime = clock_systime() / 1000; - struct haybed* bed = ¤t_thread->sleep; - - if (bed->wakeup_time) { - return (bed->wakeup_time - systime); - } - - bed->wakeup_time = systime + seconds; - - if (llist_empty(&bed->sleepers)) { - llist_append(&sched_ctx.sleepers, &bed->sleepers); - } - - store_retval(seconds); - - block_current_thread(); - schedule(); - - return 0; -} - __DEFINE_LXSYSCALL1(unsigned int, alarm, unsigned int, seconds) { struct haybed* bed = ¤t_thread->sleep; @@ -346,7 +316,7 @@ get_free_pid() { ; if (unlikely(i == MAX_PROCESS)) { - panick("Panic in Ponyville shimmer!"); + fail("Panic in Ponyville shimmer!"); } return i; @@ -396,8 +366,10 @@ alloc_process() proc->created = clock_systime(); proc->pgid = proc->pid; + proc->root = vfs_sysroot; + proc->sigreg = vzalloc(sizeof(struct sigregistry)); - proc->fdtable = vzalloc(sizeof(struct v_fdtable)); + proc->fdtable = fdtable_create(); proc->mm = procvm_create(proc); @@ -593,7 +565,7 @@ terminate_proccess(struct proc_info* proc, int exit_code) { assert(!kernel_process(proc)); if (proc->pid == 1) { - panick("Attempt to kill init"); + fail("Attempt to kill init"); } terminate_proc_only(proc, exit_code); @@ -633,4 +605,5 @@ orphaned_proc(pid_t pid) // 如果其父进程的状态是terminated 或 destroy中的一种 // 或者其父进程是在该进程之后创建的,那么该进程为孤儿进程 return proc_terminated(parent) || parent->created > proc->created; -} \ No newline at end of file +} +