fix: use wait queue for blocking process
[lunaix-os.git] / lunaix-os / kernel / process / sched.c
index 3ee0e7666c32eafe97c3436ac1c2a9ccc103f64b..caec0e67cd05acd8d6ea26bf1d828eaed2f35b64 100644 (file)
@@ -172,7 +172,8 @@ __DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
     llist_append(&root_proc->sleep.sleepers, &__current->sleep.sleepers);
 
     __current->intr_ctx.registers.eax = seconds;
-    __current->state = PS_BLOCKED;
+
+    block_current();
     schedule();
 }
 
@@ -282,6 +283,8 @@ alloc_process()
     proc->created = clock_systime();
     proc->pgid = proc->pid;
     proc->fdtable = vzalloc(sizeof(struct v_fdtable));
+    proc->fxstate =
+      vzalloc_dma(512); // FXSAVE需要十六位对齐地址,使用DMA块(128位对齐)
 
     llist_init_head(&proc->mm.regions.head);
     llist_init_head(&proc->tasks);
@@ -349,6 +352,7 @@ destroy_process(pid_t pid)
     }
 
     vfree(proc->fdtable);
+    vfree_dma(proc->fxstate);
 
     struct mm_region *pos, *n;
     llist_for_each(pos, n, &proc->mm.regions.head, head)