diff --git a/scripts/latency-histogram b/scripts/latency-histogram index 245a2c386ee..3a9001ead66 100755 --- a/scripts/latency-histogram +++ b/scripts/latency-histogram @@ -111,6 +111,24 @@ proc which_exe {name} { return -code error "$name: executable not found" } ;# which_exe +proc check_rt_privileges {} { + # Ask the realtime layer whether realtime is actually available, via + # 'realtime verify' (exits 0 when realtime is up, non-zero otherwise, + # usually a missing 'sudo make setuid' or 'sudo make setcap'). + if {[catch {exec linuxcnc_var REALTIME} rt]} return ;# cannot locate, stay quiet + if {![catch {exec $rt verify 2>@1}]} return ;# realtime available + set msg "Warning: realtime is not available." + append msg "\nThreads get no SCHED_FIFO priority or locked memory," + append msg "\nso the latency shown will be far worse than reality." + append msg "\nOn a run-in-place build, run 'sudo make setuid' (or 'sudo make setcap') in src/." + puts stderr $msg + if {$::LH(use_x)} { + package require Tk + tk_messageBox -parent . -icon warning -type ok \ + -title "Latency Warning" -message $msg + } +} ;# check_rt_privileges + proc program_check {plist} { foreach prog $plist { if [catch { @@ -624,6 +642,7 @@ proc start_collection {} { } } hal start + check_rt_privileges if {!$::LH(legacy)} { # Attach the Tcl hal_stream binding (added in halsh.c) to each # thread's latencybinstream FIFO. The handle stays open for the