diff --git a/src/hal/components/threads.c b/src/hal/components/threads.c index 33c3dc765a9..bbb7e406949 100644 --- a/src/hal/components/threads.c +++ b/src/hal/components/threads.c @@ -72,7 +72,7 @@ RTAPI_MP_LONG(period2, "thread2 period (nsecs)"); static char *name3 = NULL; /* name of thread */ RTAPI_MP_STRING(name3, "name of thread 3"); static int fp3 = 1; /* use floating point? default = yes */ -RTAPI_MP_INT(fp3, "thread1 uses floating point"); +RTAPI_MP_INT(fp3, "thread3 uses floating point"); static long period3 = 0; /* thread period - default = no thread */ RTAPI_MP_LONG(period3, "thread3 period (nsecs)"); diff --git a/src/hal/components/timedelta.comp b/src/hal/components/timedelta.comp index 46b0e6054c1..3922e8f71ad 100644 --- a/src/hal/components/timedelta.comp +++ b/src/hal/components/timedelta.comp @@ -1,11 +1,24 @@ component timedelta "LinuxCNC HAL component that measures thread scheduling timing behavior"; -pin out s32 out; -pin out s32 err=0; -pin out s32 min_=0; -pin out s32 max_=0; -pin out s32 jitter=0; -pin out float avg_err=0; -pin in bit reset; + +pin out s32 jitter=0 "Worst-case scheduling error (in ns). This is the largest discrepancy between ideal thread period, and actual time between sequential runs of this component. This uses the absolute value of the error, so 'got run too early' and 'got run too late' both show up as positive jitter."; + +pin out s32 current_jitter=0 "Scheduling error (in ns) of the current invocation. This is the discrepancy between ideal thread period, and actual time since the previous run of this component. This uses the absolute value of the error, so 'got run too early' and 'got run too late' both show up as positive jitter."; + +pin out s32 current_error=0 "Scheduling error (in ns) of the current invocation. This is the discrepancy between ideal thread period, and actual time since the previous run of this component. This does not use the absolute value of the error, so 'got run too early' shows up as negative error and 'got run too late' shows up as positive error."; + +pin out s32 min_=0 "Minimum time (in ns) between sequential runs of this component."; + +pin out s32 max_=0 "Maximum time (in ns) between sequential runs of this component."; + +pin in bit reset "Set this pin to True, then back to False, to reset some of the statistics."; + +pin out s32 out "Time (in ns) since the previous run of this component. This should ideally be equal to the thread period."; + +pin out s32 err=0 "Cumulative time error (in ns). Probably not useful."; + +pin out float avg_err=0 "The average scheduling error (in ns)."; + + function _ nofp; variable rtapi_s64 last=0; variable int first=1; @@ -30,6 +43,8 @@ if(last != 0) { if(del < min_) min_ = del; if(del > max_) max_ = del; jitter = max(max_ - period, period - min_); + current_jitter = max(del - period, period - del); + current_error = del - period; } count++; avg_err = err / (double)count; diff --git a/src/rtapi/uspace_rtapi_app.cc b/src/rtapi/uspace_rtapi_app.cc index 86198c56403..e5f870c8ac7 100644 --- a/src/rtapi/uspace_rtapi_app.cc +++ b/src/rtapi/uspace_rtapi_app.cc @@ -458,7 +458,8 @@ static int master(int fd, vector args) { perror("pthread_create (queue function)"); return -1; } - do_load_cmd("hal_lib", vector()); instance_count = 0; + do_load_cmd("hal_lib", vector()); + instance_count = 0; App(); // force rtapi_app to be created int result=0; if(args.size()) {