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

Combine initialized and shutdown flags into one #691

Closed
jphickey opened this issue Dec 14, 2020 · 0 comments · Fixed by #941 or #956
Closed

Combine initialized and shutdown flags into one #691

jphickey opened this issue Dec 14, 2020 · 0 comments · Fixed by #941 or #956
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented Dec 14, 2020

Is your feature request related to a problem? Please describe.
The OSAL global state structure has two flags, one for "initialized" (set during OS_API_Init) and one for shutdown (set during OS_ApplicationShutdown). Although similar in purpose, they are defined and work differently.

Describe the solution you'd like
Should combine these into just one state variable, which should be 0 prior to initialization (i.e. such that the application loader provided by the OS will zero it before OSAL loads), then set to a nonzero value for normal runtime, and another special nonzero value for shutdown.

Additional context
Just a suggestion for cleaning up/simplifying what is already there...

Structure defined here:

struct OS_shared_global_vars
{
bool Initialized;
/*
* The console device ID used for OS_printf() calls
*/
osal_id_t PrintfConsoleId;
/*
* PrintfEnabled and ShutdownFlag are marked "volatile"
* because they are updated and read by different threads
*/
volatile bool PrintfEnabled;
volatile uint32 ShutdownFlag;
uint32 MicroSecPerTick;
uint32 TicksPerSecond;
/*
* The event handler is an application-defined callback
* that gets invoked as resources are created/configured/deleted.
*/
OS_EventHandler_t EventHandler;
#ifdef OSAL_CONFIG_DEBUG_PRINTF
uint8 DebugLevel;
#endif
};
.

Using a full 32 bit value with all bits - even though there are only a few states - provides protection in case of a random bit flip. At least in the case of an application shutdown, the entire system operation shouldn't be dependent on a single bit in memory. This is why the current "shutdown flag" is not just a simple 0/1. So this should be preserved, but it should be trivial to combine this with the "Initialized" field.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey self-assigned this Dec 14, 2020
@skliper skliper added this to the 6.0.0 milestone Sep 24, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants