简体   繁体   中英

Linux : Signal : SIGUSR1 : Signal Handler : Measuring execution time?

I am using linux signals (specifically SIGUSR1 and SIGUSR2 ) to send signal from kernel space (linux kernel module) to the user space (an application that uses the kernel module). These signals are handled properly and the functionality is working fine.

Now I want to measure the execution time of the signal handlers(preferably in nanoseconds or microseconds).

I have tried using gprof but it does not show the execution time of the signal handlers. Apart from this it shows the execution time in seconds.

I also tried using Ftrace("nop" tracer, function_profile_enabled) but that didn't work either.

How can one measure the execution time of the signal handler?

For user space programs, read time(7) then use clock_gettime(2) with CLOCK_REALTIME to measure time. Don't expect nanoseconds accuracy.

Read also carefully signal(7) .

I would not use signals for kernel <-> user-space communication. On Linux, I would suggest using netlink(7) with netlink(3) functions (or providing a device in your kernel module for that communication). You could have some event loop to handle these (eg with poll(2) ...)

See also strace(1) ; it has crude timing facilities for syscalls...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM