Skip to content

Commit

Permalink
Rework CLR reboot (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jan 30, 2019
1 parent 97b1768 commit c7efead
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
12 changes: 9 additions & 3 deletions src/CLR/Core/Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ HRESULT CLR_RT_ExecutionEngine::DeleteInstance()

void CLR_RT_ExecutionEngine::ExecutionEngine_Cleanup()
{
/////////////////////////////////////////////////////////////////////////////////////////////////
// developer notes:
// Most of the following calls are just for pure ceremony and gracefully terminating stuff,
// cleaning collections and such.
// In particular the previous existing calls to Abort threads were completely irrelevant
// because the execution engine wasn't running anymore so whatever code that is on those threads
// there to be executed wouldn't never be executed anyways.
/////////////////////////////////////////////////////////////////////////////////////////////////

NATIVE_PROFILE_CLR_CORE();
m_fShuttingDown = true;

Expand All @@ -228,9 +237,6 @@ void CLR_RT_ExecutionEngine::ExecutionEngine_Cleanup()

m_timerThread = NULL;

AbortAllThreads ( m_threadsReady );
AbortAllThreads ( m_threadsWaiting );

ReleaseAllThreads( m_threadsReady );
ReleaseAllThreads( m_threadsWaiting );
ReleaseAllThreads( m_threadsZombie );
Expand Down
1 change: 0 additions & 1 deletion src/CLR/Include/nanoCLR_Debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ struct CLR_DBG_Commands
static const unsigned int c_EnterBootloader = 1;
static const unsigned int c_ClrOnly = 2;
static const unsigned int c_WaitForDebugger = 4;
static const unsigned int c_NoShutdown = 8;

unsigned int m_flags;
};
Expand Down
14 changes: 9 additions & 5 deletions targets/CMSIS-OS/ChibiOS/nanoCLR/CLRStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,15 @@ struct Settings

void Cleanup()
{
if(!CLR_EE_REBOOT_IS(NoShutdown))
{
// OK to delete execution engine
CLR_RT_ExecutionEngine::DeleteInstance();
}
CLR_RT_ExecutionEngine::DeleteInstance();

memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine));
memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes));
memset( &g_CLR_RT_WellKnownMethods, 0, sizeof(g_CLR_RT_WellKnownMethods));
memset( &g_CLR_RT_TypeSystem, 0, sizeof(g_CLR_RT_TypeSystem));
memset( &g_CLR_RT_EventCache, 0, sizeof(g_CLR_RT_EventCache));
memset( &g_CLR_RT_GarbageCollector, 0, sizeof(g_CLR_RT_GarbageCollector));
memset( &g_CLR_HW_Hardware, 0, sizeof(g_CLR_HW_Hardware));

m_fInitialized = false;
}
Expand Down
14 changes: 9 additions & 5 deletions targets/FreeRTOS/ESP32_DevKitC/nanoCLR/CLRStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ struct Settings

void Cleanup()
{
if(!CLR_EE_REBOOT_IS(NoShutdown))
{
// OK to delete execution engine
CLR_RT_ExecutionEngine::DeleteInstance();
}
CLR_RT_ExecutionEngine::DeleteInstance();

memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine));
memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes));
memset( &g_CLR_RT_WellKnownMethods, 0, sizeof(g_CLR_RT_WellKnownMethods));
memset( &g_CLR_RT_TypeSystem, 0, sizeof(g_CLR_RT_TypeSystem));
memset( &g_CLR_RT_EventCache, 0, sizeof(g_CLR_RT_EventCache));
memset( &g_CLR_RT_GarbageCollector, 0, sizeof(g_CLR_RT_GarbageCollector));
memset( &g_CLR_HW_Hardware, 0, sizeof(g_CLR_HW_Hardware));

m_fInitialized = false;
}
Expand Down
9 changes: 1 addition & 8 deletions targets/os/win32/nanoCLR/CLRStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,22 +394,15 @@ struct Settings

void Cleanup()
{
if(!CLR_EE_REBOOT_IS(NoShutdown))
{
// OK to delete execution engine
CLR_RT_ExecutionEngine::DeleteInstance();
}
CLR_RT_ExecutionEngine::DeleteInstance();

#if defined(_WIN32)
memset( &g_CLR_RT_ExecutionEngine, 0, sizeof(g_CLR_RT_ExecutionEngine));
memset( &g_CLR_RT_WellKnownTypes, 0, sizeof(g_CLR_RT_WellKnownTypes));

memset( &g_CLR_RT_WellKnownMethods, 0, sizeof(g_CLR_RT_WellKnownMethods));
memset( &g_CLR_RT_TypeSystem, 0, sizeof(g_CLR_RT_TypeSystem));
memset( &g_CLR_RT_EventCache, 0, sizeof(g_CLR_RT_EventCache));
memset( &g_CLR_RT_GarbageCollector, 0, sizeof(g_CLR_RT_GarbageCollector));
memset( &g_CLR_HW_Hardware, 0, sizeof(g_CLR_HW_Hardware));
#endif

m_fInitialized = false;
}
Expand Down

0 comments on commit c7efead

Please sign in to comment.