# Determining Time Spent in Kernel and User Space

http://sourceware.org/systemtap/examples/profiling/thread-times.stp

This section illustrates how to determine the amount of time any given thread is spending in either kernel or user-space.

thread-times.stp

lists the top 20 processes currently taking up CPU time within a 5-second sample, along with the total number of CPU ticks made during the sample. The output of this script also notes the percentage of CPU time each process used, as well as whether that time was spent in kernel space or user space.

contains a 5-second sample of the output for :

Sample Output

      tid   %user %kernel (of 20002 ticks)
        0   0.00%  87.88%
    32169   5.24%   0.03%
     9815   3.33%   0.36%
     9859   0.95%   0.00%
     3611   0.56%   0.12%
     9861   0.62%   0.01%
    11106   0.37%   0.02%
    32167   0.08%   0.08%
     3897   0.01%   0.08%
     3800   0.03%   0.00%
     2886   0.02%   0.00%
     3243   0.00%   0.01%
     3862   0.01%   0.00%
     3782   0.00%   0.00%
    21767   0.00%   0.00%
     2522   0.00%   0.00%
     3883   0.00%   0.00%
     3775   0.00%   0.00%
     3943   0.00%   0.00%
     3873   0.00%   0.00%

script examples determining time spent in kernel and user space
examples of SystemTap scripts determining time spent in kernel and user space
determining time spent in kernel and user space examples of SystemTap scripts
time spent in kernel/user space, determining examples of SystemTap scripts
kernel and user space, determining time spent in examples of SystemTap scripts
user and kernel space, determining time spent in examples of SystemTap scripts
script examples CPU ticks
examples of SystemTap scripts CPU ticks
CPU ticks examples of SystemTap scripts