layout boot-stage framework for aa64
[lunaix-os.git] / lunaix-os / kernel / process / sched.c
index 574d593a0db86c0960b5bfd50a830a80206c2c2c..945fc01bf6db0a8ae5edb1fcc48f867732fb3cbd 100644 (file)
@@ -73,10 +73,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();
 
@@ -550,7 +549,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 +564,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;
 
@@ -598,7 +599,7 @@ terminate_proccess(struct proc_info* proc, int exit_code) {
     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;
     }
 }