From 4c5c953d1c0c012b79058a5877323fe0188d0a19 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 25 Jun 2021 15:26:42 -0400 Subject: [PATCH] Fix #1088, avoid task delete during UtPrintf In the osal_core_UT test, the test task was being deleted while it was in the midst of a UtPrintf call, which left the BSP mutex in a locked state, causing deadlock. Using SEM_DELETE_SAFE attribute avoids task deletion for the mutex holder, and adding a small delay to the test case makes all the messages appear as expected (accounts for slow serial console on test platform). --- src/bsp/generic-vxworks/src/bsp_start.c | 4 ++-- src/unit-tests/oscore-test/ut_oscore_task_test.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bsp/generic-vxworks/src/bsp_start.c b/src/bsp/generic-vxworks/src/bsp_start.c index caa33a333..07e9e107c 100644 --- a/src/bsp/generic-vxworks/src/bsp_start.c +++ b/src/bsp/generic-vxworks/src/bsp_start.c @@ -103,8 +103,8 @@ int OS_BSPMain(void) /* * Initialize the low level access sem */ - OS_BSP_GenericVxWorksGlobal.AccessMutex = - semMInitialize(OS_BSP_GenericVxWorksGlobal.AccessMutexMem, SEM_Q_PRIORITY | SEM_INVERSION_SAFE); + OS_BSP_GenericVxWorksGlobal.AccessMutex = semMInitialize(OS_BSP_GenericVxWorksGlobal.AccessMutexMem, + SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE); if (OS_BSP_GenericVxWorksGlobal.AccessMutex == (SEM_ID)0) { diff --git a/src/unit-tests/oscore-test/ut_oscore_task_test.c b/src/unit-tests/oscore-test/ut_oscore_task_test.c index 5bb7daac1..90570478d 100644 --- a/src/unit-tests/oscore-test/ut_oscore_task_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_task_test.c @@ -163,10 +163,10 @@ void UT_os_task_create_test() { break; } - } - /* Delay to let child tasks run */ - OS_TaskDelay(500); + /* Delay to let child task run */ + OS_TaskDelay(200); + } /* Reset test environment */ for (i = 0; i < OS_MAX_TASKS; i++)