Disable rtprio by default and abort, if given prio is not allowed

This commit is contained in:
Andreas Eversberg 2024-01-07 17:44:40 +01:00
parent 3158c48365
commit 3c2b5286c5
4 changed files with 29 additions and 21 deletions

View File

@ -57,7 +57,7 @@ static int region = -1, region_advance;
static int double_amplitude = 0;
static int test_tone = 0;
static int dsp_interval = 1; /* ms */
static int rt_prio = 1;
static int rt_prio = 0;
static int fast_math = 0;
/* not static, in case we add libtimer some day, then compiler hits an error */
@ -539,6 +539,19 @@ int main(int argc, char *argv[])
timestamp = dcf77_start_weather((time_t)timestamp, region, region_advance);
}
/* set real time prio */
if (rt_prio) {
struct sched_param schedp;
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = rt_prio;
rc = sched_setscheduler(0, SCHED_RR, &schedp);
if (rc) {
fprintf(stderr, "Error setting SCHED_RR with prio %d\n", rt_prio);
goto error;
}
}
print_aaimage();
printf("DCF77 ready.\n");
@ -550,17 +563,6 @@ int main(int argc, char *argv[])
term.c_cc[VTIME]=2;
tcsetattr(0, TCSANOW, &term);
/* set real time prio */
if (rt_prio) {
struct sched_param schedp;
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = rt_prio;
rc = sched_setscheduler(0, SCHED_RR, &schedp);
if (rc)
fprintf(stderr, "Error setting SCHED_RR with prio %d\n", rt_prio);
}
signal(SIGINT, sighandler);
signal(SIGHUP, sighandler);
signal(SIGTERM, sighandler);

View File

@ -77,7 +77,7 @@ int no_l16 = 0;
int send_patterns = 1;
static int release_on_disconnect = 1;
int loopback = 0;
int rt_prio = 1;
int rt_prio = 0;
int fast_math = 0;
const char *write_tx_wave = NULL;
const char *write_rx_wave = NULL;
@ -691,9 +691,6 @@ void main_mobile_loop(const char *name, int *quit, void (*myhandler)(void), cons
if (console_open_audio(buffer_size, dsp_interval))
return;
if (!loopback)
print_aaimage();
/* real time priority */
if (rt_prio > 0) {
struct sched_param schedp;
@ -702,10 +699,15 @@ void main_mobile_loop(const char *name, int *quit, void (*myhandler)(void), cons
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = rt_prio;
rc = sched_setscheduler(0, SCHED_RR, &schedp);
if (rc)
if (rc) {
fprintf(stderr, "Error setting SCHED_RR with prio %d\n", rt_prio);
return;
}
}
if (!loopback)
print_aaimage();
/* prepare terminal */
tcgetattr(0, &term_orig);
term = term_orig;

View File

@ -42,7 +42,7 @@ enum paging_signal;
void *sender_head = NULL;
int use_sdr = 0;
int num_kanal = 1; /* only one channel used for debugging */
int rt_prio = 1;
int rt_prio = 0;
int fast_math = 0;
void *get_sender_by_empfangsfrequenz() { return NULL; }
@ -385,8 +385,10 @@ int main(int argc, char *argv[])
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = rt_prio;
rc = sched_setscheduler(0, SCHED_RR, &schedp);
if (rc)
if (rc) {
fprintf(stderr, "Error setting SCHED_RR with prio %d\n", rt_prio);
goto error;
}
}
double tx_frequencies[1], rx_frequencies[1];

View File

@ -48,7 +48,7 @@ enum paging_signal;
void *sender_head = NULL;
int use_sdr = 0;
int num_kanal = 1; /* only one channel used for debugging */
int rt_prio = 1;
int rt_prio = 0;
void *get_sender_by_empfangsfrequenz() { return NULL; }
@ -331,8 +331,10 @@ static void tx_bas(sample_t *sample_bas, __attribute__((__unused__)) sample_t *s
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = rt_prio;
rc = sched_setscheduler(0, SCHED_RR, &schedp);
if (rc)
if (rc) {
fprintf(stderr, "Error setting SCHED_RR with prio %d\n", rt_prio);
goto error;
}
}
double tx_frequencies[1], rx_frequencies[1];