diff --git a/master/master.c b/master/master.c index 7e7c3f3e..fe9b5946 100644 --- a/master/master.c +++ b/master/master.c @@ -1440,6 +1440,20 @@ void ec_master_nanosleep(const unsigned long nsecs) /*****************************************************************************/ +/* compatibility for priority changes */ +static inline void set_normal_priority(struct task_struct *p, int nice) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) + sched_set_normal(p, nice); +#else + struct sched_param param = { .sched_priority = 0 }; + sched_setscheduler(p, SCHED_NORMAL, ¶m); + set_user_nice(p, nice); +#endif +} + +/*****************************************************************************/ + /** Execute slave FSMs. */ void ec_master_exec_slave_fsms( @@ -1654,8 +1668,6 @@ static int ec_master_operation_thread(void *priv_data) */ void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */) { - struct sched_param param = { .sched_priority = 0 }; - if (master->eoe_thread) { EC_MASTER_WARN(master, "EoE already running!\n"); return; @@ -1682,8 +1694,7 @@ void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */) return; } - sched_setscheduler(master->eoe_thread, SCHED_NORMAL, ¶m); - set_user_nice(master->eoe_thread, 0); + set_normal_priority(master->eoe_thread, 0); } /*****************************************************************************/