Skip to content

Commit

Permalink
Fix nasa#1103, Implement OS_ERR_INVALID_PRIORITY return code check fo…
Browse files Browse the repository at this point in the history
…r RTEMS
  • Loading branch information
thnkslprpt committed Mar 23, 2023
1 parent 88d4b3b commit 19c3d8c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/os/inc/osapi-task.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ typedef osal_task((*osal_task_entry)(void)); /**< @brief For task entry point */
* @retval #OS_INVALID_POINTER if any of the necessary pointers are NULL
* @retval #OS_ERR_INVALID_SIZE if the stack_size argument is zero
* @retval #OS_ERR_NAME_TOO_LONG name length including null terminator greater than #OS_MAX_API_NAME
* @retval #OS_ERR_INVALID_PRIORITY if the priority is bad @covtest
* @retval #OS_ERR_INVALID_PRIORITY if the initial priority is invalid @covtest
* @retval #OS_ERR_NO_FREE_IDS if there can be no more tasks created
* @retval #OS_ERR_NAME_TAKEN if the name specified is already used by a task
* @retval #OS_ERROR if an unspecified/other error occurs @covtest
Expand Down Expand Up @@ -176,7 +176,7 @@ int32 OS_TaskDelay(uint32 millisecond);
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INVALID_ID if the ID passed to it is invalid
* @retval #OS_ERR_INVALID_PRIORITY if the priority is greater than the max allowed @covtest
* @retval #OS_ERR_INVALID_PRIORITY if the new priority is invalid @covtest
* @retval #OS_ERROR if an unspecified/other error occurs @covtest
*/
int32 OS_TaskSetPriority(osal_id_t task_id, osal_priority_t new_priority);
Expand Down
17 changes: 13 additions & 4 deletions src/os/rtems/src/os-impl-tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ int32 OS_TaskCreate_Impl(const OS_object_token_t *token, uint32 flags)
status = rtems_task_create(r_name, task->priority, task->stack_size, r_mode, r_attributes, &impl->id);

/* check if task_create failed */
if (status != RTEMS_SUCCESSFUL)
if (status == RTEMS_INVALID_PRIORITY)
{
return OS_ERR_INVALID_PRIORITY;
}
else if (status != RTEMS_SUCCESSFUL)
{
/* Provide some feedback as to why this failed */
OS_printf("rtems_task_create failed: %s\n", rtems_status_text(status));
Expand Down Expand Up @@ -230,18 +234,23 @@ int32 OS_TaskSetPriority_Impl(const OS_object_token_t *token, osal_priority_t ne
rtems_task_priority old_pri;
rtems_status_code status;
OS_impl_task_internal_record_t *impl;
int32 return_code = OS_SUCCESS;

impl = OS_OBJECT_TABLE_GET(OS_impl_task_table, *token);

/* Set RTEMS Task Priority */
status = rtems_task_set_priority(impl->id, new_priority, &old_pri);
if (status != RTEMS_SUCCESSFUL)
if (status == RTEMS_INVALID_PRIORITY)
{
return_code = OS_ERR_INVALID_PRIORITY;
}
else if (status != RTEMS_SUCCESSFUL)
{
OS_DEBUG("Unhandled task_set_priority error: %s\n", rtems_status_text(status));
return OS_ERROR;
return_code = OS_ERROR;
}

return OS_SUCCESS;
return return_code;
}

/*----------------------------------------------------------------
Expand Down

0 comments on commit 19c3d8c

Please sign in to comment.