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

vxworks osapi.c utility task doesn't exit #120

Closed
skliper opened this issue Sep 30, 2019 · 4 comments · Fixed by #667 or #680
Closed

vxworks osapi.c utility task doesn't exit #120

skliper opened this issue Sep 30, 2019 · 4 comments · Fixed by #667 or #680
Assignees
Labels
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

The vxworks osapi.c has an optional task that is started in OS_API_Init():

/*---------------------------------------------------------------------------
 * Name:    UtilityTask
 * Purpose: If turned on, this task will print out the messages from
 *          the OS_printf buffer at a low priority. This will mean
 *          that the functions calling OS_printf will not block due to
 *          writing data to the UART
----------------------------------------------------------------------------*/
#ifdef OS_UTILITY_TASK_ON
void UtilityTask()
...

However, this utility task implementation has a while(TRUE) loop with no exit logic. For a "load and forever run it" scenario this may work, but for any other scenario where an orderly shutdown is desired by the user this means the task is never killed. One can get kernel crashes if the vxworks module is unloaded while that thread is still writing to output. The forever loop thread also makes line coverage difficult.

We need a robust method to always end this thread and to ensure the parent thread doesn't return to OS control while this thread is still hanging out there.

@skliper skliper self-assigned this Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Imported from trac issue 97. Created by abrown4 on 2015-08-31T14:30:11, last modified: 2019-08-14T14:11:46

@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Trac comment by abrown4 on 2015-11-25 17:11:19:

See also #56, which adds an OS_ApplicationShutdown() and may run into the same issue when/if those changes are ported over to VxWorks.

@skliper skliper removed their assignment Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Oct 22, 2019

Note OS_ConsoleTask_Entry in posix/osapi.c is still a while(true) loop with no exit.

rtems is also a while(true) for OS_ConsoleTask_Entry in rtems/osapi.c

VxWorks task exits on semTake failure. I think that means this task will exit if the semaphore is deleted, but I also don't see it being deleted. It does facilitate being able to exit in a unit test though.

@jphickey jphickey self-assigned this Oct 23, 2019
@jphickey
Copy link
Contributor

There may be a simple fix here, by just checking the ShutdownFlag in the while loop.

skliper added a commit to skliper/osal that referenced this issue Dec 2, 2020
skliper added a commit to skliper/osal that referenced this issue Dec 2, 2020
@astrogeco astrogeco added this to the 6.0.0 milestone Dec 9, 2020
@astrogeco astrogeco added bug and removed enhancement labels Dec 9, 2020
skliper added a commit to skliper/osal that referenced this issue Dec 9, 2020
astrogeco added a commit that referenced this issue Dec 9, 2020
Fix #120, Exit console loop on shutdown
@skliper skliper removed the vxworks label Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants