]> git.corax.cc Git - corax/commitdiff
Implement sched_task_suspend() function
authorMatthias Kruk <m@m10k.eu>
Mon, 25 Nov 2019 06:08:43 +0000 (15:08 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 25 Nov 2019 06:08:43 +0000 (15:08 +0900)
kernel/core/sched.c
kernel/core/sched.h

index e0e1f4f9fca294641b65ca6063d1fa747bb6d567..00f458fbd1145becd194fb987852ca43327be511 100644 (file)
@@ -222,3 +222,31 @@ int sched_signal(pid_t pid)
 
        return(ret_val);
 }
+
+int sched_task_suspend(task_t *t)
+{
+       int ret_val;
+
+       ret_val = -EALREADY;
+
+       if(!t) {
+               t = task_get_current();
+       }
+
+       task_lock(t);
+
+       if(t->t_state != TASK_STATE_WAITING) {
+               t->t_state = TASK_STATE_WAITING;
+
+               /* remove the task from the ready queue and put it on the wait queue */
+               ret_val = _unq(&_readyq, t);
+
+               if(ret_val >= 0) {
+                   _nq(&_waitq, t);
+               }
+       }
+
+       task_unlock(t);
+
+       return(ret_val);
+}
index a37208feee1a140bc4a0050b52a38640a8c2b70c..4f54beae482e1ff1c758c592caa531b047bda7e6 100644 (file)
@@ -8,5 +8,6 @@ void sched_wait(pid_t);
 int  sched_enqueue(task_t*);
 int  sched_dequeue(task_t*);
 int  sched_signal(pid_t);
+int  sched_task_suspend(task_t*);
 
 #endif /* __CORE_SCHED_H */