Multithreaded example

Updated: April 19, 2023

In our example we'll use two threads:

Thread Priority
A High
B Low

Now we'll watch them run, assuming both start at the same time:

Note: When logging starts, the instrumented kernel sends information about each thread. Existing processes will appear to be created during this procedure.
Time Thread Action Explanation
t1 A Create Thread is created.
t2 A Block The thread is waiting for, say, I/O; it can't continue without it.
t3 B Create Rather than sit idle, the kernel runs next highest priority thread.
t4 B Kernel Call Thread B is working.
t4.5 N/A N/A I/O completed; Thread A is ready to run.
t5 B Block Thread A is now ready to run—it preempts thread B.
t6 A Run Thread A resumes.
t7 A Dies Its task complete, the thread terminates.
t8 B Runs Thread B continues from where it left off.
t9 ... ... ...