Fix order of operations for delete all
When cleaning up for shutdown, delete resources that have
a task/thread first, followed by other resource types.
This helps avoid possible dependencies as running threads
might be using the other resources.
@@ -337,7 +337,18 @@ void OS_DeleteAllObjects(void)
{
ObjectCount = 0;
++TryCount;
+
+ /* Delete timers and tasks first, as they could be actively using other object types */
+ OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TIMECB, OS_OBJECT_CREATOR_ANY,
+ OS_CleanUpObject, &ObjectCount);
+ OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TIMEBASE, OS_OBJECT_CREATOR_ANY,
+ OS_CleanUpObject, &ObjectCount);
+ OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TASK, OS_OBJECT_CREATOR_ANY,
+ OS_CleanUpObject, &ObjectCount);
+
+ /* Then try to delete all other remaining objects of any type */
OS_ForEachObject(OS_OBJECT_CREATOR_ANY, OS_CleanUpObject, &ObjectCount);
+
if (ObjectCount == 0 || TryCount > 4)
{
break;
