From 23b28766c3addb652283e5334972335e1a1d6b76 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Tue, 19 Jan 2021 15:15:13 +0800 Subject: [PATCH] sched/task: setup the scheduling policy to task Signed-off-by: chao.an --- sched/task/task_setup.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c index 891d281d52..363ac99d27 100644 --- a/sched/task/task_setup.c +++ b/sched/task/task_setup.c @@ -368,6 +368,16 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, int priority, tcb->flags &= ~TCB_FLAG_TTYPE_MASK; tcb->flags |= ttype; + /* Set the appropriate scheduling policy in the TCB */ + + tcb->flags &= ~TCB_FLAG_POLICY_MASK; +#if CONFIG_RR_INTERVAL > 0 + tcb->flags |= TCB_FLAG_SCHED_RR; + tcb->timeslice = MSEC2TICK(CONFIG_RR_INTERVAL); +#else + tcb->flags |= TCB_FLAG_SCHED_FIFO; +#endif + #ifdef CONFIG_CANCELLATION_POINTS /* Set the deferred cancellation type */