lib: cmsis_rtos_v2: Default thread prioity
If an unitialized/zeroed optional attribute was passed to osThreadNew the priority would be osThreadNone i.e. uninitialized. This causes an ASSERT to be hit as the priority isn't valid (it is not between osPriorityIdle and osPriorityISR). The fix checks the passed in priority is not osPriorityNone and assigns osPriorityNormal. This is the correct CMSIS behaviour. The ASSERT will still be hit if the priority is invalid (<0). Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
This commit is contained in:
parent
d47178bc95
commit
655d3cc2b0
1 changed files with 9 additions and 3 deletions
|
@ -98,6 +98,7 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
|
|||
const osThreadAttr_t *attr)
|
||||
{
|
||||
s32_t prio;
|
||||
osPriority_t cv2_prio;
|
||||
struct cv2_thread *tid;
|
||||
static u32_t one_time;
|
||||
void *stack;
|
||||
|
@ -117,6 +118,12 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
|
|||
attr = &init_thread_attrs;
|
||||
}
|
||||
|
||||
if (attr->priority == osPriorityNone) {
|
||||
cv2_prio = osPriorityNormal;
|
||||
} else {
|
||||
cv2_prio = attr->priority;
|
||||
}
|
||||
|
||||
if ((attr->stack_mem == NULL) && (thread_num_dynamic >=
|
||||
CONFIG_CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT)) {
|
||||
return NULL;
|
||||
|
@ -136,8 +143,7 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
|
|||
__ASSERT(attr->stack_size <= CONFIG_CMSIS_V2_THREAD_MAX_STACK_SIZE,
|
||||
"invalid stack size\n");
|
||||
|
||||
__ASSERT((attr->priority >= osPriorityIdle) &&
|
||||
(attr->priority <= osPriorityISR),
|
||||
__ASSERT((cv2_prio >= osPriorityIdle) && (cv2_prio <= osPriorityISR),
|
||||
"invalid priority\n");
|
||||
|
||||
if (attr->stack_mem != NULL) {
|
||||
|
@ -146,7 +152,7 @@ osThreadId_t osThreadNew(osThreadFunc_t threadfunc, void *arg,
|
|||
}
|
||||
}
|
||||
|
||||
prio = cmsis_to_zephyr_priority(attr->priority);
|
||||
prio = cmsis_to_zephyr_priority(cv2_prio);
|
||||
|
||||
this_thread_num = atomic_inc((atomic_t *)&thread_num);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue