aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2023-02-13 10:56:17 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2023-02-13 10:57:20 +0100
commite0b078b385258002f6829481a78ce4fc51cac34a (patch)
tree05e173921352d3f60767af16c37f75abdd2034ea
parent7716cee237fcbc371a443a39dd0f4c3f6bf8d989 (diff)
downloadethos-u-core-platform-e0b078b385258002f6829481a78ce4fc51cac34a.tar.gz
Don't lock and unlock ThreadX mutex during initialization
Change-Id: Ic308ea6b18dec1a612a198d94de918798f6304f8
-rw-r--r--applications/threadx_demo/main.cpp18
1 files 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 <open-source-office@arm.com>
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -19,7 +19,9 @@
/****************************************************************************
* Includes
****************************************************************************/
-#include "tx_api.h"
+
+#include <tx_api.h>
+#include <tx_thread.h>
#include <inttypes.h>
#include <stdio.h>
@@ -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<TX_MUTEX *>(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<TX_MUTEX *>(mutex));
if (status != TX_SUCCESS) {
printf("mutex put failed, error - %d\n", status);