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

OS_TaskDelay implementation wrt errors not consistent #1104

Open
skliper opened this issue Jul 15, 2021 · 0 comments
Open

OS_TaskDelay implementation wrt errors not consistent #1104

skliper opened this issue Jul 15, 2021 · 0 comments

Comments

@skliper
Copy link
Contributor

skliper commented Jul 15, 2021

Is your feature request related to a problem? Please describe.
In the RTEMS implementation if OS_Milli2Ticks fails (over max int) it'll wait 10 ticks, although comment is somewhat misleading since 10 isn't a minimum... passing in 0 would also cause no wait:

int32 OS_TaskDelay_Impl(uint32 milli_second)
{
int tick_count;
int32 return_code;
return_code = OS_Milli2Ticks(milli_second, &tick_count);
if (return_code != OS_SUCCESS)
{
/*
* always want to do some form of delay, because if
* this function becomes a no-op then this might create a
* tight loop that doesn't ever yield the CPU - effectively
* locking the system in an RTOS environment.
*/
tick_count = 10;
}
/*
** Always successful ( from RTEMS docs )
*/
rtems_task_wake_after((rtems_interval)tick_count);
return (return_code);
} /* end OS_TaskDelay_Impl */

VxWorks doesn't wait a minimum if OS_Milli2Ticks fails, just returns an error:
int32 OS_TaskDelay_Impl(uint32 milli_second)
{
/* msecs rounded to the closest system tick count */
int sys_ticks;
/* Convert to ticks if possible */
if (OS_Milli2Ticks(milli_second, &sys_ticks) != OS_SUCCESS)
{
return OS_ERROR;
}
/* if successful, the execution of task will pend here until delay finishes */
if (taskDelay(sys_ticks) != OK)
{
return OS_ERROR;
}
return OS_SUCCESS;
} /* end OS_TaskDelay_Impl */

POSIX just converts to timespec and uses clock_nanosleep.

Describe the solution you'd like
Technically OS_TaskDelay should be functionally tested with a 0 and max value input, not that I'd ever want to wait that long (although RTEMS and VxWorks should return quickly due to the OS_Milli2Ticks error response). It would be nice if behavior was consistent, although for 0 it looks to me like none of them would yield. If we really want a yield in all cases then it needs an update.

Describe alternatives you've considered
None.

Additional context
From functional test scrub.

Requester Info
Jacob Hageman - NASA/GSFC

jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Fix nasa#945, Finish CFE_PLATFORM_ES_PERF_MAX_IDS removal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant