From e0b078b385258002f6829481a78ce4fc51cac34a Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Mon, 13 Feb 2023 10:56:17 +0100 Subject: Don't lock and unlock ThreadX mutex during initialization Change-Id: Ic308ea6b18dec1a612a198d94de918798f6304f8 --- applications/threadx_demo/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/applications/threadx_demo/main.cpp b/applications/threadx_demo/main.cpp index 5a4a6da..0eaa55e 100644 --- a/applications/threadx_demo/main.cpp +++ b/applications/threadx_demo/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022 Arm Limited. All rights reserved. + * SPDX-FileCopyrightText: Copyright 2019-2023 Arm Limited and/or its affiliates * * SPDX-License-Identifier: Apache-2.0 * @@ -19,7 +19,9 @@ /**************************************************************************** * Includes ****************************************************************************/ -#include "tx_api.h" + +#include +#include #include #include @@ -146,6 +148,12 @@ void *ethosu_mutex_create(void) { int ethosu_mutex_lock(void *mutex) { UINT status; + + // Skip during initialization phase + if (TX_THREAD_GET_SYSTEM_STATE() != 0) { + return 0; + } + status = tx_mutex_get(reinterpret_cast(mutex), TX_WAIT_FOREVER); if (status != TX_SUCCESS) { printf("mutex get failed, error - %d\n", status); @@ -156,6 +164,12 @@ int ethosu_mutex_lock(void *mutex) { int ethosu_mutex_unlock(void *mutex) { UINT status; + + // Skip during initialization phase + if (TX_THREAD_GET_SYSTEM_STATE() != 0) { + return 0; + } + status = tx_mutex_put(reinterpret_cast(mutex)); if (status != TX_SUCCESS) { printf("mutex put failed, error - %d\n", status); -- cgit v1.2.1