#include "mbconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sched.h>
#include <errno.h>
Go to the source code of this file.
#define KEEP_STATIC_INLINE |
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 60 of file logproc.c.
62 RT_TASK *logtask, *mbdtask;
72 int dim =
sizeof(
struct data);
75 struct sched_param mysched;
77 mysched.sched_priority = 1;
80 fprintf(stderr,
"INVALID NUMBER OF ARGUMENTS: ARGC=%d\n"
82 "USAGE: logproc <MBDTSK> <MBXLOG> <CPUMAP> <NONROOT>\n",
89 CpuMap = atoi(argv[3]);
90 if (strcasecmp(argv[4],
"true") == 0) {
91 rt_allow_nonroot_hrt();
93 }
else if (strcasecmp(argv[4],
"false" ) != 0) {
94 fprintf(stderr,
"INVALID VALUE \"%s\" FOR NONROOT\n", argv[4]);
98 if (sched_setscheduler(0, SCHED_FIFO, &mysched) == -1) {
99 fputs(
"ERROR IN SETTING THE SCHEDULER UP", stderr);
104 mlockall(MCL_CURRENT | MCL_FUTURE);
106 if (!(logtask = rt_task_init_schmod(nam2num(
"LTSK"), 20, 0, 0,
107 SCHED_FIFO, CpuMap)))
109 fputs(
"CANNOT INIT LOG TASK\n", stderr);
113 if (!(mbdtask = rt_get_adr(nam2num(mbdynname)))) {
114 fprintf(stderr,
"CANNOT FIND MBDyn TASK \"%s\"\n", mbdynname);
118 rt_task_resume(mbdtask);
120 if (!(mbxlog = rt_get_adr(nam2num(mbxname)))) {
121 fprintf(stderr,
"CANNOT FIND LOG MBX\n");
125 printf(
"\n" "OVERRUNS MONITOR:\n");
126 printf(
" step t [ns]\n");
127 while (!rt_mbx_receive(mbxlog, &
msg, dim)) {
133 rt_sleep(nano2count(1000000000));
134 rt_task_delete(logtask);
135 printf(
"\n\n" "OVERRUNS MONITOR:\n");
136 printf(
"Total overruns detected: %d\n", i);
137 printf(
"Mean overruns time: %6.2lf ns\n",
138 i ? ((
double)time)/((
double)i) : 0.);
139 printf(
"End of overruns monitor.\n");