Background documentationTask Switching Locate this document in the navigation structure

 

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.

Example

The following graphic shows a simplified illustration of how three tasks in a user kernel thread run alternately.

This graphic is explained in the accompanying text.

Example: Tasks in a User Kernel Thread

Initially, Task 1 is running. Task 2 and Task 3 are runnable.

  1. Task 1 sends an I/O request and puts itself in a waiting state.

    Task 2 is the next runnable task; it resumes executing.

  2. Task 2 sends an I/O request and puts itself in a waiting state.

    Task 3 is the next runnable task; it resumes executing.

  3. The I/O operation of Task 1 is completed. Task 1 receives a corresponding message and is again runnable.

  4. Task 3 sends an I/O request and puts itself in a waiting state.

    Task 1 is the next runnable task; it resumes executing.

  5. The I/O operation of Task 2 is completed. Task 2 receives a corresponding message and is again runnable.

  6. Task 1 is completed.

    Task 2 is the next runnable task; it resumes executing.

More Information

Tasks

Threads