I have some question about the following switch in Linux Kernel, somebody can explain please the last case
, why do I need this case at all, if it is empty? thanks in advance
switch (prev->state) {
case TASK_INTERRUPTIBLE:
if (unlikely(signal_pending(prev))) {
prev->state = TASK_RUNNING;
break;
}
default:
deactivate_task(prev, rq);
case TASK_RUNNING:
;
}
I took it from linux 2.4.18, which I'm currently learning, there is no comment there about, why this way
If prev->state == TASK_RUNNING
and you don't have the last case, then deactivate_task
will be called, which is presumably not desired here. This is just a quick way of doing something special for TASK_INTERRUPTIBLE
and something different for every other state but TASK_RUNNING
.
Following is what they do there:
If prev->state == TASK_RUNNING -> do nothing.
If prev->state == TASK_INTERRUPTIBLE - > signal_pending() and then possibly deactivate_task()
In any other case just deactivate_task().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With