Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hal/components/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)");

Expand Down
29 changes: 22 additions & 7 deletions src/hal/components/timedelta.comp
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/rtapi/uspace_rtapi_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ static int master(int fd, vector<string> args) {
perror("pthread_create (queue function)");
return -1;
}
do_load_cmd("hal_lib", vector<string>()); instance_count = 0;
do_load_cmd("hal_lib", vector<string>());
instance_count = 0;
App(); // force rtapi_app to be created
int result=0;
if(args.size()) {
Expand Down