/* constants */
-#define RT_PRIO 80
//#define N 32
#define N 10
#define BREATH 20
char *version = "0.1";
int nb_threads = 1;
+int sched_rt_prio = 50;
/* types */
fprintf (fd, " -h: help message\n");
fprintf (fd, " -n: number of thread (%d)\n", nb_threads);
fprintf (fd, " -n: print version\n");
+ fprintf (fd, " -r: real-time priority, -1 to desactivate (%d)\n", sched_rt_prio);
fprintf (fd, "%s version %s\n", progname, version);
return ret;
double val;
get_matrix (matrix, 0, l, &val);
det += sign * val * determinant (comatrix);
- usleep (BREATH);
+ //usleep (BREATH);
}
free_matrix (comatrix);
double val = base * (rand () - RAND_MAX / 2) / (double)RAND_MAX;
set_matrix (matrix, i, j, val);
}
- usleep (BREATH);
+ //usleep (BREATH);
}
}
}
nb_threads = atoi (arg);
break;
+ case 'r':
+ arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
+ if (arg == NULL) {
+ fprintf (stderr, "%s: real-time scheduler mode not specified\n", progname);
+ return usage (1);
+ }
+ sched_rt_prio = atoi (arg);
+ break;
case 'v':
printf ("version: %s\n", version);
break;
}
}
-#if 1
- /* real-time process */
+ if (sched_rt_prio >= 0) {
+
+ /* real-time process */
+
+ struct sched_param param = {0};
+ if (sched_getparam (0, ¶m) != 0) {
+ fprintf (stderr, "error: sched_getparam\n");
+ return 1;
+ }
+ param.sched_priority = sched_rt_prio;
+ int rc = sched_setscheduler (0, SCHED_FIFO, ¶m); /* non-preemptive */
+ // int rc = sched_setscheduler (0, SCHED_RR, ¶m); /* preemptive */
+ if (rc != 0) {
+ fprintf (stderr, "error: sched_setscheduler\n");
+ return 1;
+ }
- struct sched_param param = {0};
- if (sched_getparam (0, ¶m) != 0) {
- fprintf (stderr, "error: sched_getparam\n");
- return 1;
- }
- param.sched_priority = RT_PRIO;
- int rc = sched_setscheduler (0, SCHED_FIFO, ¶m); /* non-preemptive */
- // int rc = sched_setscheduler (0, SCHED_RR, ¶m); /* preemptive */
- if (rc != 0) {
- fprintf (stderr, "error: sched_setscheduler\n");
- return 1;
}
-#endif
/* main process */