Merge branch 'sched_setscheduler' into 'stable-1.5'

Fix sched_setscheduler undefined on kernel 5.9

See merge request etherlab.org/ethercat!1
This commit is contained in:
Florian Pose 2021-03-05 15:25:56 +00:00
commit 2c962eea38
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);
}
/*****************************************************************************/