Fix sched_setscheduler undefined on kernel 5.9

sched_setscheduler is no more exported:
    https://lkml.org/lkml/2020/4/22/1071
This commit is contained in:
Nicola Fontana 2021-02-28 20:47:46 +01:00
parent 7fd991bec7
commit 2600c89390
1 changed files with 15 additions and 4 deletions

View File

@ -1447,6 +1447,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, &param);
set_user_nice(p, nice);
#endif
}
/*****************************************************************************/
/** Execute slave FSMs.
*/
void ec_master_exec_slave_fsms(
@ -1666,8 +1680,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;
@ -1693,8 +1705,7 @@ void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */)
return;
}
sched_setscheduler(master->eoe_thread, SCHED_NORMAL, &param);
set_user_nice(master->eoe_thread, 0);
set_normal_priority(master->eoe_thread, 0);
}
/*****************************************************************************/