fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / kernel / process / sched.c
index 574d593a0db86c0960b5bfd50a830a80206c2c2c..112741c553de299db541357d39baca3487d9f373 100644 (file)
@@ -1,7 +1,7 @@
-#include <sys/abi.h>
-#include <sys/mm/mempart.h>
+#include <asm/abi.h>
+#include <asm/mempart.h>
 
-#include <sys/cpu.h>
+#include <asm/cpu.h>
 
 #include <lunaix/fs/taskfs.h>
 #include <lunaix/mm/cake.h>
 #include <lunaix/hart_state.h>
 #include <lunaix/kpreempt.h>
 
-#include <lunaix/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;
@@ -73,10 +71,9 @@ run(struct thread* thread)
     clean-up on these thread, in the preemptible kernel thread.
 */
 
-void _preemptible
-cleanup_detached_threads() {
-    ensure_preempt_caller();
-
+void
+cleanup_detached_threads() 
+{
     // XXX may be a lock on sched_context will ben the most appropriate?
     cpu_disable_interrupt();
 
@@ -222,7 +219,6 @@ schedule()
     sched_ctx.procs_index = to_check->process->pid;
 
 done:
-    isrm_notify_eos(0);
     run(to_check);
 
     fail("unexpected return from scheduler");
@@ -347,7 +343,7 @@ get_free_pid() {
         ;
     
     if (unlikely(i == MAX_PROCESS)) {
-        panick("Panic in Ponyville shimmer!");
+        fail("Panic in Ponyville shimmer!");
     }
 
     return i;
@@ -397,6 +393,8 @@ 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));
 
@@ -550,7 +548,7 @@ delete_process(struct proc_info* proc)
 
 pid_t
 destroy_process(pid_t pid)
-{
+{    
     int index = pid;
     if (index <= 0 || index > sched_ctx.ptable_len) {
         syscall_result(EINVAL);
@@ -565,6 +563,8 @@ destroy_process(pid_t pid)
 
 static void 
 terminate_proc_only(struct proc_info* proc, int exit_code) {
+    assert(proc->pid != 0);
+
     proc->state = PS_TERMNAT;
     proc->exit_code = exit_code;
 
@@ -592,13 +592,13 @@ 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);
 
     struct thread *pos, *n;
-    llist_for_each(pos, n, &__current->threads, proc_sibs) {
+    llist_for_each(pos, n, &proc->threads, proc_sibs) {
         pos->state = PS_TERMNAT;
     }
 }