Don't lock and unlock ThreadX mutex during initialization

Change-Id: Ic308ea6b18dec1a612a198d94de918798f6304f8
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 @@
 
 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_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);