]> git.corax.cc Git - corax/commitdiff
Add sched_task_resume() function
authorMatthias Kruk <m@m10k.eu>
Mon, 25 Nov 2019 07:20:32 +0000 (16:20 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 25 Nov 2019 07:20:32 +0000 (16:20 +0900)
kernel/core/sched.c
kernel/include/sched.h

index 15a8a0f18668c4bcc311c2e66d36a365a6418e0f..1d73477cd6f07196e024faa80f487987dbaffe9e 100644 (file)
@@ -257,3 +257,34 @@ int sched_task_suspend(task_t *t)
 
        return(ret_val);
 }
+
+int sched_task_resume(task_t *t)
+{
+       int ret_val;
+
+       /*
+        * Make sure the task is currently in the TASK_STATE_WAITING state.
+        * If it is, change its state to TASK_STATE_READY.
+        */
+       task_lock(t);
+
+       if(t->t_state == TASK_STATE_WAITING) {
+               t->t_state = TASK_STATE_READY;
+               ret_val = 0;
+       } else {
+               ret_val = -EBUSY;
+       }
+
+       task_unlock(t);
+
+       /* if the task was waiting, remove it from the waitq and add it to the readyq */
+       if(!ret_val) {
+               ret_val = _unq(&_waitq, t);
+
+               if(ret_val >= 0) {
+                       _nq(&_readyq, t);
+               }
+       }
+
+       return(ret_val);
+}
index 4f54beae482e1ff1c758c592caa531b047bda7e6..65efeb9bbc823a32fefdc3d4348a783f4c292a4a 100644 (file)
@@ -9,5 +9,6 @@ int  sched_enqueue(task_t*);
 int  sched_dequeue(task_t*);
 int  sched_signal(pid_t);
 int  sched_task_suspend(task_t*);
+int  sched_task_resume(task_t*);
 
 #endif /* __CORE_SCHED_H */