Preemption is not to move non-running processes out of the dispatch queue.
task_running: Running or in ready state: The ready state refers to all the resources that the process has requested outside of the CPU, so-called: everything is prepared, only the east wind. Reminders: General operating system textbooks define processes that are executing on the CPU as RUNNING states, A process that is executable but not yet scheduled for execution is defined as a ready state, and the two states are unified to the Task_running state under Linux. Task_interruptible: Waiting for a queue to wake up when the resource is active (such as waiting for keyboard input, Socket connection, signal, etc.), but can be interrupted to wake up. In general, most processes in the process list are in Task_ Interruptible state. After all, the emperor had only one (single CPU), harem thousands of; if not most of the processes are asleep, the CPU responds. task_uninterruptible: In the waiting team, Wait for the resource to wake up when it is active (such as waiting for keyboard input, socket connection, signal, and so on), but cannot be interrupted. Task_zombie: Zombie state, the process resource user space is freed, but the process PCB in the kernel is not released, waiting for the parent process to recycle. Task_stopped: The process is suspended by an external program (such as receiving a sigstop signal, the process goes into the task_stopped state) and continues when allowed again (process receives sigcont signal, enters task_running state), So the process in this state can be awakened after creating a process with kthread_create and setting the process state to task_interruptible, the running state of the current process does not change and remains in the execution state. Example: int thread_do (void* arg) {__set_current_state (task_interruptible), while (!kthread_should_stop ()) {PRINTK ("***\n") ); //schedule (); }return 0;} static int __init t_init (void) {p = kthread_create (Thread_do, NULL, "TASK1"); wake_up_process (p); return 0;} After the WAKE_UP process p, it will always print * * *. __set_cUrrent_state (task_interruptible); just set a status bit of the process and did nothing. If you do not call schedule (), you will not move the current process from the run queue to the waiting queue, so the current task is running the queue. So it can be executed all the time. kthread_create is a thread that waits for an event to fire after it is created. Kthread_run is a thread that is created after a direct wake-up thread begins to run.
Linux Process scheduling