-
Notifications
You must be signed in to change notification settings - Fork 253
Description
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:
osal/src/os/shared/inc/os-shared-common.h
Lines 40 to 67 in 9407cdf
| 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.