refactor: add a async read/write variant to device ops, with allow async io to be...
[lunaix-os.git] / lunaix-os / kernel / process / sched.c
index aa75714b0dcc9aeb6378a61d79ac48ef4264a9bb..bec2faef33af8cc4591949602359bc89d7bd0335 100644 (file)
@@ -42,9 +42,8 @@ sched_init()
     proc_pile = cake_new_pile("proc", sizeof(struct proc_info), 1, 0);
     cake_set_constructor(proc_pile, cake_ctor_zeroing);
 
     proc_pile = cake_new_pile("proc", sizeof(struct proc_info), 1, 0);
     cake_set_constructor(proc_pile, cake_ctor_zeroing);
 
-    sched_ctx = (struct scheduler){ ._procs = vzalloc(PROC_TABLE_SIZE),
-                                    .ptable_len = 0,
-                                    .procs_index = 0 };
+    sched_ctx = (struct scheduler){
+        ._procs = vzalloc(PROC_TABLE_SIZE), .ptable_len = 0, .procs_index = 0};
 
     // TODO initialize dummy_proc
     sched_init_dummy();
 
     // TODO initialize dummy_proc
     sched_init_dummy();
@@ -96,6 +95,9 @@ can_schedule(struct proc_info* proc)
     if ((proc->state & PS_PAUSED)) {
         return !!(sh->sig_pending & ~1);
     }
     if ((proc->state & PS_PAUSED)) {
         return !!(sh->sig_pending & ~1);
     }
+    if ((proc->state & PS_BLOCKED)) {
+        return sigset_test(sh->sig_pending, _SIGINT);
+    }
 
     if (sigset_test(sh->sig_pending, _SIGCONT)) {
         sigset_clear(sh->sig_pending, _SIGSTOP);
 
     if (sigset_test(sh->sig_pending, _SIGCONT)) {
         sigset_clear(sh->sig_pending, _SIGSTOP);
@@ -324,6 +326,8 @@ alloc_process()
     llist_init_head(&proc->children);
     llist_init_head(&proc->grp_member);
     llist_init_head(&proc->sleep.sleepers);
     llist_init_head(&proc->children);
     llist_init_head(&proc->grp_member);
     llist_init_head(&proc->sleep.sleepers);
+
+    iopoll_init(&proc->pollctx);
     waitq_init(&proc->waitqueue);
 
     sched_ctx._procs[i] = proc;
     waitq_init(&proc->waitqueue);
 
     sched_ctx._procs[i] = proc;
@@ -373,6 +377,8 @@ destroy_process(pid_t pid)
     llist_delete(&proc->tasks);
     llist_delete(&proc->sleep.sleepers);
 
     llist_delete(&proc->tasks);
     llist_delete(&proc->sleep.sleepers);
 
+    iopoll_free(pid, &proc->pollctx);
+
     taskfs_invalidate(pid);
 
     if (proc->cwd) {
     taskfs_invalidate(pid);
 
     if (proc->cwd) {