check a priority requested before filling tcb 13/115913/2
authorsunghan <sh924.chang@samsung.com>
Wed, 22 Feb 2017 04:55:38 +0000 (13:55 +0900)
committerKwon TaeJun <tj80.kwon@samsung.com>
Wed, 22 Feb 2017 08:53:11 +0000 (00:53 -0800)
Change-Id: Ie0787ea2ced7f5f07619fab8d57903283339b48f

os/kernel/task/task_setup.c

index ce7e115..ba0327d 100644 (file)
@@ -354,6 +354,14 @@ static int thread_schedsetup(FAR struct tcb_s *tcb, int priority, start_t start,
        if (ret == OK) {
                /* Save task priority and entry point in the TCB */
 
+               if (priority < SCHED_PRIORITY_MIN) {
+                       svdbg("WARNING: Requested priority is lower than min value (1)\n");
+                       priority = SCHED_PRIORITY_MIN;
+               } else if (priority > SCHED_PRIORITY_MAX) {
+                       svdbg("WARNING: Requested priority is higher than max value (255)\n");
+                       priority = SCHED_PRIORITY_MAX;
+               }
+
                tcb->sched_priority = (uint8_t)priority;
 #ifdef CONFIG_PRIORITY_INHERITANCE
                tcb->base_priority = (uint8_t)priority;