dedicated kthread interface and enablement of lrud auto-recycler
[lunaix-os.git] / lunaix-os / kernel / process / sched.c
index 31775bfdf7c36d19c77120c3a67d76da2e11d747..ccf0e45aac1935ace616b2800188521f1e2263df 100644 (file)
 #include <lunaix/hart_state.h>
 #include <lunaix/kpreempt.h>
 
-#include <asm-generic/isrm.h>
-
 #include <klibc/string.h>
 
 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 = &current_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 = &current_thread->sleep;
@@ -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);
     
@@ -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
+}
+