#! /usr/bin/env stap # # global time_offset probe begin { time_offset = gettimeofday_us() printf("monitor begin==========\n") } probe scheduler.cpu_off { if(task_execname(task_next)=="test2") { t = gettimeofday_us(); printf("%9d : %20s(%6d)->%10s(%6d:%6d)\n", t-time_offset, task_execname(task_prev), task_pid(task_prev), task_execname(task_next), task_pid(task_next), #返回的是内核中的TGID task_tid(task_next)) #返回的内核中的PID } }