Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1103, Implement OS_ERR_INVALID_PRIORITY return code check for RTEMS #1378

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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