In a user kernel thread, a maximum of one task can use the processor, that is, be in the running state. All other tasks are either in the runnable state or are waiting for an external event, such as the end of an I/O operation and a corresponding message, to become runnable again.
If the current task no longer needs the processor, it triggers a task switch (cooperative task switch) and the next task in the same user kernel thread can use the processor.
The following graphic shows a simplified illustration of how three tasks in a user kernel thread run alternately.
Example: Tasks in a User Kernel Thread
Initially, Task 1 is running. Task 2 and Task 3 are runnable.
Task 1 sends an I/O request and puts itself in a waiting state.
Task 2 is the next runnable task; it resumes executing.
Task 2 sends an I/O request and puts itself in a waiting state.
Task 3 is the next runnable task; it resumes executing.
The I/O operation of Task 1 is completed. Task 1 receives a corresponding message and is again runnable.
Task 3 sends an I/O request and puts itself in a waiting state.
Task 1 is the next runnable task; it resumes executing.
The I/O operation of Task 2 is completed. Task 2 receives a corresponding message and is again runnable.
Task 1 is completed.
Task 2 is the next runnable task; it resumes executing.